Allow using the "%" variable in git commands

Closes https://github.com/tpope/vim-fugitive/issues/686

For example, when running:

  :Git add %

neovim throws the following exception:

  E499: Empty file name for '%' or '#',
  only works with ":p:h": terminal git add %

It is a result of the tabnew command, it creates a new blank tab where
"%" is empty.

This commit changes "tabnew" to "tabedit %" so you're still working on
the same file.

Once the command is done running the tab closes.
This commit is contained in:
David Elentok
2015-09-10 22:20:18 +03:00
committed by Tim Pope
parent b319b69453
commit b7b23001de

View File

@@ -683,7 +683,7 @@ function! s:Git(bang, args) abort
let args = matchstr(a:args,'\v\C.{-}%($|\\@<!%(\\\\)*\|)@=')
if exists(':terminal')
let dir = s:repo().tree()
tabnew
tabedit %
execute 'lcd' fnameescape(dir)
execute 'terminal' git args
else