Skip to content

Commit

Permalink
Reformat command postfix to (PID/label)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mvanderkamp committed Aug 14, 2021
1 parent 359c628 commit fc9747b
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions autoload/dispatch.vim
Original file line number Diff line number Diff line change
Expand Up @@ -371,15 +371,12 @@ endfunction

function! s:postfix(request) abort
let pid = dispatch#pid(a:request)
return '(' . a:request.handler.'/'.(!empty(pid) ? pid : '?') . ')'
let label = get(a:request, 'label', 'Running')
return '(' . (!empty(pid) ? pid : '?') . '/' . label . ')'
endfunction

function! s:status_label(request) abort
let label = get(a:request, 'label', '') . get(a:request, 'status', '')
if !empty(label)
return '(' . label . ')'
endif
return ''
function! s:quickfix_title(request) abort
return ':Dispatch '.dispatch#escape(a:request.expanded) . ' ' . s:postfix(a:request)
endfunction

function! s:echo_truncated(left, right) abort
Expand Down Expand Up @@ -1219,24 +1216,22 @@ function! dispatch#complete(file, ...) abort
endif
if has_key(request, 'aborted')
echohl DispatchAbortedMsg
let label = 'Aborted:'
let request.label = 'Aborted'
elseif status > 0
echohl DispatchFailureMsg
let label = 'Failure:'
let request.label = 'Failure'
elseif status == 0
echohl DispatchSuccessMsg
let label = 'Success:'
let request.label = 'Success'
else
echohl DispatchCompleteMsg
let label = 'Complete:'
let request.label = 'Complete'
endif
let request.label = label
let request.status = status
if !request.background && !get(request, 'aborted')
call s:cwindow(request, 0, status, '', 'make')
redraw!
endif
call s:echo_truncated(label . '!', request.expanded . ' ' . s:postfix(request))
call s:echo_truncated('!', request.expanded . ' ' . s:postfix(request))
echohl NONE
if !a:0
checktime
Expand Down Expand Up @@ -1316,18 +1311,18 @@ function! s:cgetfile(request, event, ...) abort
let &l:efm = request.format
endif
let &l:makeprg = dispatch#escape(request.expanded)
let title = ':Dispatch '.dispatch#escape(request.expanded) . ' ' . s:postfix(request)
if len(a:event)
exe 'silent doautocmd QuickFixCmdPre' a:event
endif
if exists(':chistory') && stridx(get(getqflist({'title': 1}), 'title', ''), title) >= 0
let title = s:quickfix_title(request)
let title_to_match = title[:strridx(title, '/')]
if exists(':chistory') && stridx(get(getqflist({'title': 1}), 'title', ''), title_to_match) >= 0
call setqflist([], 'r')
execute 'noautocmd caddfile' dispatch#fnameescape(request.file)
else
execute 'noautocmd cgetfile' dispatch#fnameescape(request.file)
endif
if exists(':chistory')
let title .= ' ' . s:status_label(request)
call setqflist([], 'r', {'title': title})
endif
if len(a:event)
Expand Down

0 comments on commit fc9747b

Please sign in to comment.