commit 8388b6d0fb5d3031369fd77751d6087f5330b340 (tree)
parent 7ae214e445c0ea21c56ec7e92851b85a23d4ea54
Author: Tim Pope <code@tpope.net>
Date: Wed, 4 Mar 2020 10:29:45 -0500
Use status headers for commit maps
Closes https://github.com/tpope/vim-fugitive/issues/1485
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim
@@ -5822,6 +5822,8 @@ endfunction
" Section: Go to file
+let s:ref_header = '\%(Head\|Merge\|Rebase\|Upstream\|Pull\|Push\)'
+
nnoremap <SID>: :<C-U><C-R>=v:count ? v:count : ''<CR>
function! fugitive#MapCfile(...) abort
exe 'cnoremap <buffer> <expr> <Plug><cfile>' (a:0 ? a:1 : 'fugitive#Cfile()')
@@ -5842,7 +5844,7 @@ endfunction
function! s:SquashArgument(...) abort
if &filetype == 'fugitive'
- let commit = matchstr(getline('.'), '^\%(\%(\x\x\x\)\@!\l\+\s\+\)\=\zs[0-9a-f]\{4,\}\ze ')
+ let commit = matchstr(getline('.'), '^\%(\%(\x\x\x\)\@!\l\+\s\+\)\=\zs[0-9a-f]\{4,\}\ze \|^' . s:ref_header . ': \zs\S\+')
elseif has_key(s:temp_files, s:cpath(expand('%:p')))
let commit = matchstr(getline('.'), '\<\x\{4,\}\>')
else
@@ -6036,7 +6038,7 @@ function! s:StatusCfile(...) abort
return [lead . info.relative[0]]
elseif len(info.commit)
return [info.commit]
- elseif line =~# '^\%(Head\|Merge\|Rebase\|Upstream\|Pull\|Push\): '
+ elseif line =~# '^' . s:ref_header . ': '
return [matchstr(line, ' \zs.*')]
else
return ['']