Provide some <mods> handling on quickfix commands

Most notably, don't force an early redraw with :silent.

Closes https://github.com/tpope/vim-fugitive/issues/1685
This commit is contained in:
Tim Pope
2021-02-27 08:18:28 -05:00
parent fad16e502a
commit 601bf2e225

View File

@@ -626,7 +626,8 @@ function! s:QuickfixCreate(nr, opts) abort
endif endif
endfunction endfunction
function! s:QuickfixStream(nr, event, title, cmd, first, callback, ...) abort function! s:QuickfixStream(nr, event, title, cmd, first, mods, callback, ...) abort
let mods = s:Mods(a:mods)
let opts = {'title': a:title, 'context': {'items': []}} let opts = {'title': a:title, 'context': {'items': []}}
call s:QuickfixCreate(a:nr, opts) call s:QuickfixCreate(a:nr, opts)
let event = (a:nr < 0 ? 'c' : 'l') . 'fugitive-' . a:event let event = (a:nr < 0 ? 'c' : 'l') . 'fugitive-' . a:event
@@ -647,8 +648,10 @@ function! s:QuickfixStream(nr, event, title, cmd, first, callback, ...) abort
call extend(opts.context.items, contexts) call extend(opts.context.items, contexts)
unlet contexts unlet contexts
call s:QuickfixSet(a:nr, remove(buffer, 0, -1), 'a') call s:QuickfixSet(a:nr, remove(buffer, 0, -1), 'a')
if mods !~# '\<silent\>'
redraw redraw
endif endif
endif
endfor endfor
call extend(buffer, call(a:callback, a:000 + [0])) call extend(buffer, call(a:callback, a:000 + [0]))
call extend(opts.context.items, map(copy(buffer), 'get(v:val, "context", {})')) call extend(opts.context.items, map(copy(buffer), 'get(v:val, "context", {})'))
@@ -658,7 +661,7 @@ function! s:QuickfixStream(nr, event, title, cmd, first, callback, ...) abort
silent exe s:DoAutocmd('QuickFixCmdPost ' . event) silent exe s:DoAutocmd('QuickFixCmdPost ' . event)
if a:first && len(s:QuickfixGet(a:nr)) if a:first && len(s:QuickfixGet(a:nr))
call s:BlurStatus() call s:BlurStatus()
return a:nr < 0 ? 'cfirst' : 'lfirst' return mods . (a:nr < 0 ? 'cfirst' : 'lfirst')
else else
return 'exe' return 'exe'
endif endif
@@ -4053,7 +4056,7 @@ function! s:ToolStream(line1, line2, range, bang, mods, options, args, state) ab
let exec += a:options.flags + ['--no-pager', 'diff', '--no-ext-diff', '--no-color', '--no-prefix'] + argv let exec += a:options.flags + ['--no-pager', 'diff', '--no-ext-diff', '--no-color', '--no-prefix'] + argv
if prompt if prompt
let title = ':Git ' . s:fnameescape(a:options.flags + [a:options.command] + a:options.args) let title = ':Git ' . s:fnameescape(a:options.flags + [a:options.command] + a:options.args)
return s:QuickfixStream(a:line2, 'difftool', title, exec, !a:bang, s:function('s:ToolParse'), a:state) return s:QuickfixStream(a:line2, 'difftool', title, exec, !a:bang, a:mods, s:function('s:ToolParse'), a:state)
else else
let filename = '' let filename = ''
let cmd = [] let cmd = []
@@ -4436,7 +4439,7 @@ function! fugitive#LogCommand(line1, count, range, bang, mods, args, type) abort
if empty(paths + extra_paths) && empty(a:type) && a:count < 0 && len(s:Relative('/')) if empty(paths + extra_paths) && empty(a:type) && a:count < 0 && len(s:Relative('/'))
let after = '|echohl WarningMsg|echo ' . string('Use :0Glog or :0Gclog for old behavior of targeting current file') . '|echohl NONE' . after let after = '|echohl WarningMsg|echo ' . string('Use :0Glog or :0Gclog for old behavior of targeting current file') . '|echohl NONE' . after
endif endif
return s:QuickfixStream(listnr, 'log', title, s:UserCommandList(dir) + cmd, !a:bang, s:function('s:LogParse'), state, dir) . after return s:QuickfixStream(listnr, 'log', title, s:UserCommandList(dir) + cmd, !a:bang, a:mods, s:function('s:LogParse'), state, dir) . after
endfunction endfunction
" Section: :Gedit, :Gpedit, :Gsplit, :Gvsplit, :Gtabedit, :Gread " Section: :Gedit, :Gpedit, :Gsplit, :Gvsplit, :Gtabedit, :Gread