Add experimental behavior for X on commit line

Resolves: https://github.com/tpope/vim-fugitive/issues/1847
This commit is contained in:
Tim Pope
2021-09-25 10:19:21 -04:00
parent 915c050724
commit 7b05afd548

View File

@@ -4804,9 +4804,13 @@ function! s:StageDelete(lnum1, lnum2, count) abort
let err = '' let err = ''
let did_conflict_err = 0 let did_conflict_err = 0
let reset_commit = matchstr(getline(a:lnum1), '^Un\w\+ \%(to\| from\) \zs\S\+')
try try
for info in s:Selection(a:lnum1, a:lnum2) for info in s:Selection(a:lnum1, a:lnum2)
if empty(info.paths) if empty(info.paths)
if len(info.commit)
let reset_commit = info.commit . '^'
endif
continue continue
endif endif
let sub = get(get(get(b:fugitive_files, info.section, {}), info.filename, {}), 'submodule') let sub = get(get(get(b:fugitive_files, info.section, {}), info.filename, {}), 'submodule')
@@ -4872,15 +4876,14 @@ function! s:StageDelete(lnum1, lnum2, count) abort
let err .= '|echoerr ' . string(v:exception) let err .= '|echoerr ' . string(v:exception)
endtry endtry
if empty(restore) if empty(restore)
if len(reset_commit) && empty(err)
call feedkeys(':Git reset ' . reset_commit)
endif
return err[1:-1] return err[1:-1]
endif endif
exe s:ReloadStatus() exe s:ReloadStatus()
call s:StageReveal() call s:StageReveal()
if len(restore) return 'checktime|redraw|echomsg ' . string('To restore, ' . join(restore, '|')) . err
return 'checktime|redraw|echomsg ' . string('To restore, ' . join(restore, '|')) . err
else
return 'checktime|redraw' . err
endif
endfunction endfunction
function! s:StageIgnore(lnum1, lnum2, count) abort function! s:StageIgnore(lnum1, lnum2, count) abort