Set loclist not qflist title for :Gllog

This commit is contained in:
Tim Pope 2019-07-09 09:47:24 -04:00
parent 9556e59765
commit fb66f9a86d

View File

@ -3347,6 +3347,22 @@ if !exists('g:fugitive_summary_format')
let g:fugitive_summary_format = '%s' let g:fugitive_summary_format = '%s'
endif endif
function! s:GetLocList(nr, ...) abort
if a:nr < 0
return call('getqflist', a:000)
else
return call('getloclist', [a:nr] + a:000)
endif
endfunction
function! s:SetLocList(nr, ...) abort
if a:nr < 0
return call('setqflist', a:000)
else
return call('setloclist', [a:nr] + a:000)
endif
endfunction
function! s:GrepComplete(A, L, P) abort function! s:GrepComplete(A, L, P) abort
return s:CompleteSubcommand('grep', a:A, a:L, a:P) return s:CompleteSubcommand('grep', a:A, a:L, a:P)
endfunction endfunction
@ -3356,6 +3372,7 @@ function! s:LogComplete(A, L, P) abort
endfunction endfunction
function! s:Grep(cmd,bang,arg) abort function! s:Grep(cmd,bang,arg) abort
let listnr = a:cmd =~# '^l' ? 0 : -1
let grepprg = &grepprg let grepprg = &grepprg
let grepformat = &grepformat let grepformat = &grepformat
try try
@ -3367,7 +3384,7 @@ function! s:Grep(cmd,bang,arg) abort
endif endif
let args = s:SplitExpand(a:arg) let args = s:SplitExpand(a:arg)
exe a:cmd.'! '.escape(s:shellesc(args), '|#%') exe a:cmd.'! '.escape(s:shellesc(args), '|#%')
let list = a:cmd =~# '^l' ? getloclist(0) : getqflist() let list = s:GetLocList(listnr)
for entry in list for entry in list
if bufname(entry.bufnr) =~ ':' if bufname(entry.bufnr) =~ ':'
let entry.filename = s:Generate(bufname(entry.bufnr)) let entry.filename = s:Generate(bufname(entry.bufnr))
@ -3379,13 +3396,11 @@ function! s:Grep(cmd,bang,arg) abort
let changed = 1 let changed = 1
endif endif
endfor endfor
if a:cmd =~# '^l' && exists('changed') if exists('changed')
call setloclist(0, list, 'r') call s:SetLocList(listnr, list, 'r')
elseif exists('changed')
call setqflist(list, 'r')
endif endif
if !a:bang && !empty(list) if !a:bang && !empty(list)
return (a:cmd =~# '^l' ? 'l' : 'c').'first' return (listnr < 0 ? 'c' : 'l').'first'
else else
return '' return ''
endif endif
@ -3398,6 +3413,7 @@ endfunction
function! s:Log(type, bang, line1, line2, args) abort function! s:Log(type, bang, line1, line2, args) abort
let dir = s:Dir() let dir = s:Dir()
let listnr = a:type =~# '^l' ? 0 : -1
let args = s:SplitExpand(a:args, s:Tree(dir)) let args = s:SplitExpand(a:args, s:Tree(dir))
let split = index(args, '--') let split = index(args, '--')
if split > 0 if split > 0
@ -3438,9 +3454,9 @@ function! s:Log(type, bang, line1, line2, args) abort
let module = "%[%^\t]%#" let module = "%[%^\t]%#"
endif endif
let &grepformat = '%Cdiff %.%#,%C--- %.%#,%C+++ %.%#,%Z@@ -%\d%\+\,%\d%\+ +%l\,%\d%\+ @@,%-G-%.%#,%-G+%.%#,%-G %.%#,%-G,%A%f' . "\t\t" . module . "\t\t%m" let &grepformat = '%Cdiff %.%#,%C--- %.%#,%C+++ %.%#,%Z@@ -%\d%\+\,%\d%\+ +%l\,%\d%\+ @@,%-G-%.%#,%-G+%.%#,%-G %.%#,%-G,%A%f' . "\t\t" . module . "\t\t%m"
silent! exe (a:type ==# 'l' ? 'lgrep' : 'grep') . '!' . escape(s:shellesc(args + paths), '|') silent! exe (listnr < 0 ? 'grep' : 'lgrep') . '!' . escape(s:shellesc(args + paths), '|')
if exists(':chistory') if exists(':chistory')
call setqflist([], 'a', {'title': (a:type ==# 'l' ? ':Gllog ' : ':Glog ') . s:fnameescape(args + paths)}) call s:SetLocList(listnr, [], 'a', {'title': (listnr < 0 ? ':Glog ' : ':Gllog ') . s:fnameescape(args + paths)})
endif endif
redraw! redraw!
finally finally
@ -3452,7 +3468,7 @@ function! s:Log(type, bang, line1, line2, args) abort
if winnr != winnr() if winnr != winnr()
wincmd p wincmd p
endif endif
if !a:bang && len(a:type ==# 'l' ? getloclist(0) : getqflist()) if !a:bang && len(s:GetLocList(listnr))
return a:type . 'first' return a:type . 'first'
endif endif
return '' return ''