Skip to content

Commit fc9747b

Browse files
committed
Reformat command postfix to (PID/label)
For example, instead of (tmux/12345), show (12345/Running). 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 359c628 commit fc9747b

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

autoload/dispatch.vim

+12-17
Original file line numberDiff line numberDiff line change
@@ -371,15 +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 . ')'
375376
endfunction
376377

377-
function! s:status_label(request) abort
378-
let label = get(a:request, 'label', '') . get(a:request, 'status', '')
379-
if !empty(label)
380-
return '(' . label . ')'
381-
endif
382-
return ''
378+
function! s:quickfix_title(request) abort
379+
return ':Dispatch '.dispatch#escape(a:request.expanded) . ' ' . s:postfix(a:request)
383380
endfunction
384381

385382
function! s:echo_truncated(left, right) abort
@@ -1219,24 +1216,22 @@ function! dispatch#complete(file, ...) abort
12191216
endif
12201217
if has_key(request, 'aborted')
12211218
echohl DispatchAbortedMsg
1222-
let label = 'Aborted:'
1219+
let request.label = 'Aborted'
12231220
elseif status > 0
12241221
echohl DispatchFailureMsg
1225-
let label = 'Failure:'
1222+
let request.label = 'Failure'
12261223
elseif status == 0
12271224
echohl DispatchSuccessMsg
1228-
let label = 'Success:'
1225+
let request.label = 'Success'
12291226
else
12301227
echohl DispatchCompleteMsg
1231-
let label = 'Complete:'
1228+
let request.label = 'Complete'
12321229
endif
1233-
let request.label = label
1234-
let request.status = status
12351230
if !request.background && !get(request, 'aborted')
12361231
call s:cwindow(request, 0, status, '', 'make')
12371232
redraw!
12381233
endif
1239-
call s:echo_truncated(label . '!', request.expanded . ' ' . s:postfix(request))
1234+
call s:echo_truncated('!', request.expanded . ' ' . s:postfix(request))
12401235
echohl NONE
12411236
if !a:0
12421237
checktime
@@ -1316,18 +1311,18 @@ function! s:cgetfile(request, event, ...) abort
13161311
let &l:efm = request.format
13171312
endif
13181313
let &l:makeprg = dispatch#escape(request.expanded)
1319-
let title = ':Dispatch '.dispatch#escape(request.expanded) . ' ' . s:postfix(request)
13201314
if len(a:event)
13211315
exe 'silent doautocmd QuickFixCmdPre' a:event
13221316
endif
1323-
if exists(':chistory') && stridx(get(getqflist({'title': 1}), 'title', ''), title) >= 0
1317+
let title = s:quickfix_title(request)
1318+
let title_to_match = title[:strridx(title, '/')]
1319+
if exists(':chistory') && stridx(get(getqflist({'title': 1}), 'title', ''), title_to_match) >= 0
13241320
call setqflist([], 'r')
13251321
execute 'noautocmd caddfile' dispatch#fnameescape(request.file)
13261322
else
13271323
execute 'noautocmd cgetfile' dispatch#fnameescape(request.file)
13281324
endif
13291325
if exists(':chistory')
1330-
let title .= ' ' . s:status_label(request)
13311326
call setqflist([], 'r', {'title': title})
13321327
endif
13331328
if len(a:event)

0 commit comments

Comments
 (0)