diff --git a/autoload/magit/state.vim b/autoload/magit/state.vim index cebbe232f0e319dcbf11653fe9e90d82f128cb63..27df64089b7776909f9516eb01ad9916ff8e96a8 100644 --- a/autoload/magit/state.vim +++ b/autoload/magit/state.vim @@ -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 diff --git a/plugin/magit.vim b/plugin/magit.vim index 86078177b83b6ed03d983a2e1ba751a413aa58f8..317667b02e0d88d7ac720d8c4ce7aa45986d746a 100644 --- a/plugin/magit.vim +++ b/plugin/magit.vim @@ -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 ) - call s:mg_display_files(a:mode, filename, a:depth + 1) - continue - endif - endif - - if ( file.visible == 0 ) - put ='' - continue + if ( file.put() != 0 ) + call s:mg_display_files(a:mode, filename, a:depth + 1) 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