Skip to content

Commit 1d891fc

Browse files
committed
Report command status in the quickfix title
For example, instead of (tmux/12345), show (12345/Success), or (12345/Running) if the command hasn't finished yet. This is helpful in cases where it is difficult at a glance for a user to tell whether their command succeeded just from reading the output. This is updated in all cases where a postfix is added to command in messages to the user, including the quickfix title. For updating quickfix lists, the title up to the '/' character in the postfix is used.
1 parent 00e77d9 commit 1d891fc

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

autoload/dispatch.vim

+18-12
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,12 @@ endfunction
371371

372372
function! s:postfix(request) abort
373373
let pid = dispatch#pid(a:request)
374-
return '(' . a:request.handler.'/'.(!empty(pid) ? pid : '?') . ')'
374+
let label = get(a:request, 'label', 'Running')
375+
return '(' . (!empty(pid) ? pid : '?') . '/' . label . ')'
376+
endfunction
377+
378+
function! s:quickfix_title(request) abort
379+
return ':Dispatch '.dispatch#escape(a:request.expanded) . ' ' . s:postfix(a:request)
375380
endfunction
376381

377382
function! s:echo_truncated(left, right) abort
@@ -1232,24 +1237,24 @@ function! dispatch#complete(file, ...) abort
12321237
if !a:0
12331238
silent doautocmd ShellCmdPost
12341239
endif
1235-
if !request.background && !get(request, 'aborted')
1236-
call s:cwindow(request, 0, status, '', 'make')
1237-
redraw!
1238-
endif
12391240
if has_key(request, 'aborted')
12401241
echohl DispatchAbortedMsg
1241-
let label = 'Aborted:'
1242+
let request.label = 'Aborted'
12421243
elseif status > 0
12431244
echohl DispatchFailureMsg
1244-
let label = 'Failure:'
1245+
let request.label = 'Failure'
12451246
elseif status == 0
12461247
echohl DispatchSuccessMsg
1247-
let label = 'Success:'
1248+
let request.label = 'Success'
12481249
else
12491250
echohl DispatchCompleteMsg
1250-
let label = 'Complete:'
1251+
let request.label = 'Complete'
1252+
endif
1253+
if !request.background && !get(request, 'aborted')
1254+
call s:cwindow(request, 0, status, '', 'make')
1255+
redraw!
12511256
endif
1252-
call s:echo_truncated(label . ' !', request.expanded . ' ' . s:postfix(request))
1257+
call s:echo_truncated('!', request.expanded . ' ' . s:postfix(request))
12531258
echohl NONE
12541259
if !a:0
12551260
checktime
@@ -1327,11 +1332,12 @@ function! s:cgetfile(request, event, ...) abort
13271332
let &l:efm = request.format
13281333
endif
13291334
let &l:makeprg = dispatch#escape(request.expanded)
1330-
let title = ':Dispatch '.dispatch#escape(request.expanded) . ' ' . s:postfix(request)
13311335
if len(a:event)
13321336
exe s:doautocmd('QuickFixCmdPre ' . a:event)
13331337
endif
1334-
if exists(':chistory') && get(getqflist({'title': 1}), 'title', '') ==# title
1338+
let title = s:quickfix_title(request)
1339+
let title_to_match = title[:strridx(title, '/')]
1340+
if exists(':chistory') && stridx(get(getqflist({'title': 1}), 'title', ''), title_to_match) >= 0
13351341
call setqflist([], 'r')
13361342
execute 'noautocmd caddfile' dispatch#fnameescape(request.file)
13371343
else

0 commit comments

Comments
 (0)