diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index eb140bc..75c6200 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1728,8 +1728,6 @@ function! fugitive#BufReadStatus() abort let nowait = v:version >= 704 ? '' : '' nunmap P nunmap ~ - nnoremap :execute StageNext(v:count1) - nnoremap :execute StagePrevious(v:count1) nnoremap [[ :execute PreviousSection(v:count1) nnoremap ]] :execute NextSection(v:count1) exe "nnoremap " nowait "- :execute Do('Toggle',0)" @@ -1758,8 +1756,6 @@ function! fugitive#BufReadStatus() abort nnoremap ds :execute StageDiff('Ghdiffsplit') nnoremap dp :execute StageDiffEdit() nnoremap dv :execute StageDiff('Gvdiffsplit') - nnoremap J :execute StageNext(v:count1) - nnoremap K :execute StagePrevious(v:count1) nnoremap P :execute StagePatch(line('.'),line('.')+v:count1-1) xnoremap P :execute StagePatch(line("'<"),line("'>")) if empty(mapcheck('q')) @@ -2155,7 +2151,7 @@ function! s:StageJump(offset, section, ...) abort let line = search('^' . a:section, 'nw') if line exe line - return s:StageNext(a:offset ? a:offset : 1) + return s:NextFileHunk(a:offset ? a:offset : 1) endif return '' endfunction @@ -2547,24 +2543,20 @@ function! s:StageReveal(...) abort endif endfunction -function! s:StageNext(count) abort +function! s:NextFileHunk(count) abort for i in range(a:count) - call search('^[A-Z?] .\|^[0-9a-f]\{4,\} \|^@','W') + call search('^[A-Z?] .\|^diff --\|^[0-9a-f]\{4,\} \|^@','W') endfor call s:StageReveal() return '.' endfunction -function! s:StagePrevious(count) abort - if line('.') == 1 && exists(':CtrlP') && get(g:, 'ctrl_p_map') =~? '^$' - return 'CtrlP '.fnameescape(s:Tree()) - else - for i in range(a:count) - call search('^[A-Z?] .\|^[0-9a-f]\{4,\} \|^@','Wbe') - endfor - call s:StageReveal() - return '.' - endif +function! s:PreviousFileHunk(count) abort + for i in range(a:count) + call search('^[A-Z?] .\|^diff --\|^[0-9a-f]\{4,\} \|^@','Wbe') + endfor + call s:StageReveal() + return '.' endfunction function! s:NextSection(count) abort @@ -2675,7 +2667,7 @@ function! s:StageIntend(count) abort else call s:StageInline('show', line('.'), 1) endif - call s:StageNext(1) + call s:NextFileHunk(1) endfor return '.' endfunction @@ -4691,6 +4683,18 @@ function! fugitive#MapJumps(...) abort nnoremap P :exe 'Gedit ' . fnameescape(ContainingCommit().'^'.v:count1.Relative(':')) nnoremap ~ :exe 'Gedit ' . fnameescape(ContainingCommit().'~'.v:count1.Relative(':')) nnoremap C :exe 'Gedit ' . fnameescape(ContainingCommit()) + + if exists(':CtrlP') && get(g:, 'ctrl_p_map') =~? '^$' + nnoremap :execute line('.') == 1 ? 'CtrlP ' . fnameescape(Tree()) : PreviousFileHunk(v:count1) + else + nnoremap :execute PreviousFileHunk(v:count1) + endif + nnoremap :execute NextFileHunk(v:count1) + nnoremap ( :execute PreviousFileHunk(v:count1) + nnoremap ) :execute NextFileHunk(v:count1) + nnoremap K :execute PreviousFileHunk(v:count1) + nnoremap J :execute NextFileHunk(v:count1) + nnoremap co :echoerr 'Use CTRL-W C' nnoremap C :exe 'Gsplit ' . fnameescape(ContainingCommit()) nnoremap cp :echoerr 'Use gC'