diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index f1201b9..9341483 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -448,7 +448,7 @@ call s:add_methods('buffer',['getvar','setvar','getline','repo','type','name','c " }}}1 " Git {{{1 -call s:command("-bar -bang -nargs=? -complete=customlist,s:GitComplete Git :call s:Git(0,)") +call s:command("-bang -nargs=? -complete=customlist,s:GitComplete Git :execute s:Git(0,)") function! s:ExecuteInTree(cmd) abort let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd ' : 'cd ' @@ -466,8 +466,10 @@ function! s:Git(bang,cmd) abort if has('gui_running') && !has('win32') let git .= ' --no-pager' endif - call s:ExecuteInTree('!'.git.' '.a:cmd) + let cmd = matchstr(a:cmd,'\v\C.{-}%($|\\@0,)") +call s:command("-bang -nargs=? -complete=customlist,s:EditComplete Ggrep :execute s:Grep(0,)") call s:command("-bar -bang -nargs=* -complete=customlist,s:EditComplete Glog :execute s:Log('grep',)") function! s:Grep(bang,arg) abort @@ -750,7 +752,7 @@ function! s:Grep(bang,arg) abort execute cd.'`=s:repo().tree()`' let &grepprg = s:repo().git_command('--no-pager', 'grep', '-n') let &grepformat = '%f:%l:%m' - exe 'grep! '.a:arg + exe 'grep! '.escape(matchstr(a:arg,'\v\C.{-}%($|[''" ]\@=\|)@='),'|') let list = getqflist() for entry in list if bufname(entry.bufnr) =~ ':' @@ -763,9 +765,9 @@ function! s:Grep(bang,arg) abort endfor call setqflist(list,'r') if !a:bang && !empty(list) - return 'cfirst' + return 'cfirst'.matchstr(a:arg,'\v\C[''" ]\zs\|.*') else - return '' + return matchstr(a:arg,'\v\C[''" ]\|\zs.*') endif finally let &grepprg = grepprg