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