Select neighboring file after "-" in :Gstatus

This commit is contained in:
Tim Pope
2010-02-14 13:03:26 -05:00
parent 1e7648cfdd
commit 55c47729ef

View File

@@ -532,10 +532,7 @@ function! s:StageToggle(lnum1,lnum2) abort
if getline('.') == '# Changes to be committed:' if getline('.') == '# Changes to be committed:'
return 'Gcommit' return 'Gcommit'
endif endif
let filename = matchstr(line,'^#\t[[:alpha:] ]\+: *\zs.*') let filename = matchstr(line,'^#\t\%([[:alpha:] ]\+: *\)\=\zs.*')
if filename ==# ''
let filename = matchstr(line,'^#\t\zs.*')
endif
if filename ==# '' if filename ==# ''
continue continue
endif endif
@@ -557,10 +554,15 @@ function! s:StageToggle(lnum1,lnum2) abort
let output .= call(s:repo().git_chomp_in_tree,cmd,s:repo())."\n" let output .= call(s:repo().git_chomp_in_tree,cmd,s:repo())."\n"
endfor endfor
if exists('first_filename') if exists('first_filename')
let jump = first_filename
let f = matchstr(getline(a:lnum1-1),'^#\t\%([[:alpha:] ]\+: *\)\=\zs.*')
if f !=# '' | let jump = f | endif
let f = matchstr(getline(a:lnum2+1),'^#\t\%([[:alpha:] ]\+: *\)\=\zs.*')
if f !=# '' | let jump = f | endif
silent! edit! silent! edit!
1 1
redraw redraw
call search('^#\t\%([[:alpha:] ]\+: *\)\=\V'.first_filename.'\$','W') call search('^#\t\%([[:alpha:] ]\+: *\)\=\V'.jump.'\$','W')
endif endif
echo s:sub(s:gsub(output,'\n+','\n'),'\n$','') echo s:sub(s:gsub(output,'\n+','\n'),'\n$','')
catch /^fugitive:/ catch /^fugitive:/
@@ -580,10 +582,7 @@ function! s:StagePatch(lnum1,lnum2) abort
elseif line == '# Changed but not updated:' elseif line == '# Changed but not updated:'
return 'Git add --patch' return 'Git add --patch'
endif endif
let filename = matchstr(line,'^#\t[[:alpha:] ]\+: *\zs.*') let filename = matchstr(line,'^#\t\%([[:alpha:] ]\+: *\)\=\zs.*')
if filename ==# ''
let filename = matchstr(line,'^#\t\zs.*')
endif
if filename ==# '' if filename ==# ''
continue continue
endif endif