commit 4ea84b29eb0f1f95bb7f6fb6a0213689eaf981d6 (tree)
parent 7bee1113e3d1810f4e8d26202eb0644b4d5fba7b
Author: Tim Pope <code@tpope.net>
Date: Fri, 19 Mar 2021 00:51:44 -0400
Default coo to identifier under cursor in temp buffers
I initially intended to do a :Git branch specific version of this, but
`:Git checkout bad-argument --` is mostly harmless, so hack it for now.
Closes https://github.com/tpope/vim-fugitive/issues/1572
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim
@@ -6099,7 +6099,7 @@ function! fugitive#MapJumps(...) abort
call s:Map('n', 'co<Space>', ':Git checkout<Space>')
call s:Map('n', 'co<CR>', ':Git checkout<CR>')
- call s:Map('n', 'coo', ':<C-U>Git checkout <C-R>=<SID>SquashArgument()<CR> --<CR>')
+ call s:Map('n', 'coo', ':<C-U>Git checkout <C-R>=substitute(<SID>SquashArgument(),"^$",get(<SID>TempState(),"filetype","") ==# "git" ? expand("<cfile>") : "","")<CR> --<CR>')
call s:Map('n', 'co?', ':<C-U>help fugitive_co<CR>', '<silent>')
call s:Map('n', 'cb<Space>', ':Git branch<Space>')