-
-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use v:echospace to avoid hit-Enter prompts #285
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -363,6 +363,55 @@ function! s:postfix(request) abort | |
return '(' . a:request.handler.'/'.(!empty(pid) ? pid : '?') . ')' | ||
endfunction | ||
|
||
function! s:echo_truncated(msg, suffix) abort | ||
redraw | ||
|
||
if exists('v:echospace') | ||
if strwidth(a:msg.' '.a:suffix) > v:echospace | ||
let msg = printf('%.*S...', v:echospace - 3 - len(a:suffix), a:msg) | ||
else | ||
let msg = a:msg | ||
endif | ||
echo msg.' '.a:suffix | ||
return | ||
blueyed marked this conversation as resolved.
Show resolved
Hide resolved
|
||
endif | ||
|
||
let suffix_len = len(substitute(a:suffix, '.', '.', 'g')) | ||
let max_cmd_len = (&cmdheight * &columns) - 2 - suffix_len - 2 | ||
|
||
if has('cmdline_info') | ||
let last_has_status = (&laststatus == 2 || (&laststatus == 1 && winnr('$') != 1)) | ||
|
||
if &ruler && !last_has_status | ||
if empty(&rulerformat) | ||
" Default ruler is 17 chars wide. | ||
let max_cmd_len -= 17 | ||
elseif exists('g:rulerwidth') | ||
" User specified width of custom ruler. | ||
let max_cmd_len -= g:rulerwidth | ||
else | ||
" Don't know width of custom ruler, make a conservative guess. | ||
let max_cmd_len -= &columns / 2 | ||
endif | ||
let max_cmd_len -= 1 | ||
endif | ||
if &showcmd | ||
let max_cmd_len -= 10 | ||
if !&ruler || last_has_status | ||
let max_cmd_len -= 1 | ||
endif | ||
endif | ||
endif | ||
|
||
let msg_len = len(substitute(a:msg, '.', '.', 'g')) | ||
if msg_len > max_cmd_len | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could also use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it ain't broke don't fix it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Character length rather than byte length. |
||
let msg = '<' . matchstr(a:msg, '\v.{'.(max_cmd_len - 1).'}$') | ||
else | ||
let msg = a:msg | ||
endif | ||
echo msg.' '.a:suffix | ||
endfunction | ||
|
||
function! s:dispatch(request) abort | ||
for handler in g:dispatch_handlers | ||
if get(g:, 'dispatch_no_' . handler . '_' . get(a:request, 'action')) || | ||
|
@@ -374,44 +423,7 @@ function! s:dispatch(request) abort | |
let a:request.handler = handler | ||
|
||
" Display command, avoiding hit-enter prompt. | ||
redraw | ||
let msg = ':!' | ||
let suffix = s:postfix(a:request) | ||
let suffix_len = len(substitute(suffix, '.', '.', 'g')) | ||
let max_cmd_len = (&cmdheight * &columns) - 2 - suffix_len - 2 | ||
|
||
if has('cmdline_info') | ||
let last_has_status = (&laststatus == 2 || (&laststatus == 1 && winnr('$') != 1)) | ||
|
||
if &ruler && !last_has_status | ||
if empty(&rulerformat) | ||
" Default ruler is 17 chars wide. | ||
let max_cmd_len -= 17 | ||
elseif exists('g:rulerwidth') | ||
" User specified width of custom ruler. | ||
let max_cmd_len -= g:rulerwidth | ||
else | ||
" Don't know width of custom ruler, make a conservative guess. | ||
let max_cmd_len -= &columns / 2 | ||
endif | ||
let max_cmd_len -= 1 | ||
endif | ||
if &showcmd | ||
let max_cmd_len -= 10 | ||
if !&ruler || last_has_status | ||
let max_cmd_len -= 1 | ||
endif | ||
endif | ||
endif | ||
let cmd = a:request.expanded | ||
let cmd_len = len(substitute(cmd, '.', '.', 'g')) | ||
if cmd_len > max_cmd_len | ||
let msg .= '<' . matchstr(cmd, '\v.{'.(max_cmd_len - 1).'}$') | ||
else | ||
let msg .= cmd | ||
endif | ||
let msg .= ' '.suffix | ||
echo msg | ||
call s:echo_truncated(':!'.a:request.expanded, s:postfix(a:request)) | ||
return response | ||
endif | ||
endfor | ||
|
@@ -1210,7 +1222,7 @@ function! dispatch#complete(file, ...) abort | |
call s:cwindow(request, 0, status, '', 'make') | ||
redraw! | ||
endif | ||
echo label '!'.request.expanded s:postfix(request) | ||
call s:echo_truncated(printf('%s !%s', label, request.expanded), s:postfix(request)) | ||
if !a:0 | ||
checktime | ||
endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use the
<
notation from the other format, not an ellipsis.