Provide count on blob blame maps for --reverse

This commit is contained in:
Tim Pope 2019-08-13 20:38:17 -04:00
parent c21736dde7
commit 5defa72b81
2 changed files with 22 additions and 13 deletions

View File

@ -145,7 +145,7 @@ endfunction
let s:nowait = v:version >= 704 ? '<nowait>' : '' let s:nowait = v:version >= 704 ? '<nowait>' : ''
function! s:map(mode, lhs, rhs, ...) abort function! s:Map(mode, lhs, rhs, ...) abort
let flags = (a:0 ? a:1 : '') . (a:rhs =~# '<Plug>' ? '' : '<script>') let flags = (a:0 ? a:1 : '') . (a:rhs =~# '<Plug>' ? '' : '<script>')
let head = a:lhs let head = a:lhs
let tail = '' let tail = ''
@ -173,6 +173,10 @@ function! s:map(mode, lhs, rhs, ...) abort
endif endif
endfunction endfunction
function! s:map(...) abort
return call('s:Map', a:000)
endfunction
" Section: Quickfix " Section: Quickfix
function! s:QuickfixGet(nr, ...) abort function! s:QuickfixGet(nr, ...) abort
@ -5333,19 +5337,18 @@ endfunction
function! fugitive#MapJumps(...) abort function! fugitive#MapJumps(...) abort
if !&modifiable if !&modifiable
if get(b:, 'fugitive_type', '') ==# 'blob' if get(b:, 'fugitive_type', '') ==# 'blob'
nnoremap <buffer> <silent> <CR> :<C-U>0,1Gblame<CR> let blame_map = 'Gblame<C-R>=v:count ? " --reverse" : ""<CR><CR>'
nnoremap <buffer> <silent> o :<C-U>0,2Gblame<CR> call s:Map('n', '<CR>', ':<C-U>0,1' . blame_map, '<silent>')
nnoremap <buffer> <silent> S :<C-U>echoerr 'Use gO'<CR> call s:Map('n', 'o', ':<C-U>0,2' . blame_map, '<silent>')
nnoremap <buffer> <silent> gO :<C-U>0,4Gblame<CR> call s:Map('n', 'p', ':<C-U>0,3' . blame_map, '<silent>')
nnoremap <buffer> <silent> O :<C-U>0,5Gblame<CR> call s:Map('n', 'gO', ':<C-U>0,4' . blame_map, '<silent>')
nnoremap <buffer> <silent> p :<C-U>0,3Gblame<CR> call s:Map('n', 'O', ':<C-U>0,5' . blame_map, '<silent>')
else else
nnoremap <buffer> <silent> <CR> :<C-U>exe <SID>GF("edit")<CR> call s:Map('n', '<CR>', ':<C-U>exe <SID>GF("edit")<CR>', '<silent>')
nnoremap <buffer> <silent> o :<C-U>exe <SID>GF("split")<CR> call s:Map('n', 'o', ':<C-U>exe <SID>GF("split")<CR>', '<silent>')
nnoremap <buffer> <silent> S :<C-U>echoerr 'Use gO'<CR> call s:Map('n', 'gO', ':<C-U>exe <SID>GF("vsplit")<CR>', '<silent>')
nnoremap <buffer> <silent> gO :<C-U>exe <SID>GF("vsplit")<CR> call s:Map('n', 'O', ':<C-U>exe <SID>GF("tabedit")<CR>', '<silent>')
nnoremap <buffer> <silent> O :<C-U>exe <SID>GF("tabedit")<CR> call s:Map('n', 'p', ':<C-U>exe <SID>GF("pedit")<CR>', '<silent>')
nnoremap <buffer> <silent> p :<C-U>exe <SID>GF("pedit")<CR>
if exists(':CtrlP') && get(g:, 'ctrl_p_map') =~? '^<c-p>$' if exists(':CtrlP') && get(g:, 'ctrl_p_map') =~? '^<c-p>$'
nnoremap <buffer> <silent> <C-P> :<C-U>execute line('.') == 1 ? 'CtrlP ' . fnameescape(<SID>Tree()) : <SID>PreviousItem(v:count1)<CR> nnoremap <buffer> <silent> <C-P> :<C-U>execute line('.') == 1 ? 'CtrlP ' . fnameescape(<SID>Tree()) : <SID>PreviousItem(v:count1)<CR>
@ -5368,6 +5371,7 @@ function! fugitive#MapJumps(...) abort
call s:MapEx('[]', 'exe <SID>PreviousSectionEnd(v:count1)') call s:MapEx('[]', 'exe <SID>PreviousSectionEnd(v:count1)')
call s:MapEx('][', 'exe <SID>NextSectionEnd(v:count1)') call s:MapEx('][', 'exe <SID>NextSectionEnd(v:count1)')
endif endif
call s:Map('n', 'S', ':<C-U>echoerr "Use gO"<CR>', '<silent>')
exe "nnoremap <buffer> <silent>" s:nowait "- :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>NavigateUp(v:count1))<Bar> if getline(1) =~# '^tree \x\{40,\}$' && empty(getline(2))<Bar>call search('^'.escape(expand('#:t'),'.*[]~\').'/\=$','wc')<Bar>endif<CR>" exe "nnoremap <buffer> <silent>" s:nowait "- :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>NavigateUp(v:count1))<Bar> if getline(1) =~# '^tree \x\{40,\}$' && empty(getline(2))<Bar>call search('^'.escape(expand('#:t'),'.*[]~\').'/\=$','wc')<Bar>endif<CR>"
nnoremap <buffer> <silent> P :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit().'^'.v:count1.<SID>Relative(':'))<CR> nnoremap <buffer> <silent> P :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit().'^'.v:count1.<SID>Relative(':'))<CR>
nnoremap <buffer> <silent> ~ :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit().'~'.v:count1.<SID>Relative(':'))<CR> nnoremap <buffer> <silent> ~ :<C-U>exe 'Gedit ' . <SID>fnameescape(<SID>ContainingCommit().'~'.v:count1.<SID>Relative(':'))<CR>

View File

@ -314,6 +314,11 @@ Navigation mappings ~
*fugitive_<CR>* *fugitive_<CR>*
<CR> Open the file or |fugitive-object| under the cursor. <CR> Open the file or |fugitive-object| under the cursor.
in a blob, this and similar maps jump to the patch
from the diff where this was added, or where it was
removed if a count was given. If the line is still in
the work tree version, passing a count takes you to
it.
*fugitive_o* *fugitive_o*
o Open the file or |fugitive-object| under the cursor in o Open the file or |fugitive-object| under the cursor in