Skip to content
Snippets Groups Projects
Commit 5ca538ed authored by Jerome Reybert's avatar Jerome Reybert Committed by Jerome Reybert
Browse files

autoload/state.vim: file object handles itself its display

parent f27f5456
No related branches found
No related tags found
No related merge requests found
......@@ -96,6 +96,31 @@ function! magit#state#file_set_diff(val) dict
endif
endfunction
function! magit#state#file_put() dict
"if ( self.dirty != 0 )
if (1)
let bufnr = magit#utils#bufnr()
let self.sign_start = magit#sign#add_sign(line('.'), 'S', bufnr)
put =file.get_filename_header()
if ( self.dir != 0 )
if ( self.visible == 1 )
let self.sign_end = magit#sign#add_sign(line('.'), 'E', bufnr)
return 1
endif
endif
if ( self.visible == 0 )
let self.sign_end = magit#sign#add_sign(line('.'), 'E', bufnr)
return 0
endif
if ( self.exists == 0 )
echoerr "Error, " . self.filename . " should not exists"
endif
let hunk_lines=self.get_flat_hunks()
silent put =hunk_lines
let self.sign_end = magit#sign#add_sign(line('.'), 'E', bufnr)
endif
endfunction
" s:hunk_template: template for hunk object (nested in s:diff_template)
" WARNING: this variable must be deepcopy()'ied
let s:hunk_template = {
......@@ -144,6 +169,7 @@ let s:file_template = {
\ 'get_flat_hunks' : function("magit#state#file_get_flat_hunks"),
\ 'toggle_visible' : function("magit#state#toggle_file_visible"),
\ 'must_be_added' : function("magit#state#must_be_added"),
\ 'put' : function("magit#state#file_put"),
\}
" magit#state#get_file: function accessor for file
......
......@@ -141,35 +141,13 @@ function! s:mg_display_files(mode, curdir, depth)
" FIXME: ouch, must store subdirs in more efficient way
for filename in sort(keys(s:state.get_files(a:mode)))
let file = s:state.get_file(a:mode, filename, 0)
let file = s:state.get_file(a:mode, filename)
if ( file.depth != a:depth || filename !~ a:curdir . '.*' )
continue
endif
put =file.get_filename_header()
if ( file.dir != 0 )
if ( file.visible == 1 )
if ( file.put() != 0 )
call s:mg_display_files(a:mode, filename, a:depth + 1)
continue
endif
endif
if ( file.visible == 0 )
put =''
continue
endif
if ( file.exists == 0 )
echoerr "Error, " . filename . " should not exists"
endif
let hunks = file.get_hunks()
for hunk in hunks
if ( hunk.header != '' )
silent put =hunk.header
endif
if ( !empty(hunk.lines) )
silent put =hunk.lines
endif
endfor
put =''
endfor
endfunction
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment