-
-
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
s:dispatch: shorten displayed message to avoid hit-enter prompt #167
Conversation
See https://github.com/vim-scripts/ingo-library/blob/558132e2221db3af26dc2f2c6756d092d48a459f/autoload/ingo/avoidprompt.vim#L31 for a more evolved method to get the maxlength correctly (instead of just |
autoload/dispatch.vim
Outdated
let suffix = ' ('.handler.'/'.(!empty(pid) ? pid : '?').')' | ||
let cmd = a:request.expanded | ||
" NOTE: the extra "-12" is required to avoid the hit-enter, although | ||
" it's displayed on a single line already?! |
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 also be done in |
What about the suggestion from #166 (comment):
This would display it normally, but skip it in case there would have been a hit-enter prompt. |
Would love to see this PR or a similar change in vim-dispatch. |
83e68d9
to
9ed7d5e
Compare
Rebased (old head: 0722f74). |
9ed7d5e
to
bc6e0af
Compare
autoload/dispatch.vim
Outdated
" NOTE: the extra "-13" is required to avoid the hit-enter, although | ||
" it's displayed on a single line already?! | ||
let max_cmd_len = (&cmdheight * &columns)-2-len(suffix)-13 | ||
if len(cmd) > max_cmd_len |
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.
len()
is byte length, it only works for ASCII. Use len(substitute(cmd, '.', '.', 'g'))
to get the number of characters.
Maybe this explains the 12/13 discrepancy?
autoload/dispatch.vim
Outdated
" it's displayed on a single line already?! | ||
let max_cmd_len = (&cmdheight * &columns)-2-len(suffix)-13 | ||
if len(cmd) > max_cmd_len | ||
let msg .= cmd[0:max_cmd_len-2] . '…' |
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.
Use '<' . matchstr(cmd, '\{' . max_cmd_length - 1 . '\}$')
to get the correct length and match Vim's usual truncation (avoiding any encoding issues from the ellipsis in the process).
No. Requiring more there is a bug in Neovim, and this patch here should maybe cope for that, but I'll look into getting it fixed there also. |
The difference is due to (not) using |
Even with (re)setting showcmd it will overwrite the tail when (re)setting it. But until it is fixed (and for older versions) I think we should check the two settings (ruler, showcmd) and take those into account for the max length. |
Improve, based on Vim's code (comp_col), inspired by https://github.com/vim-scripts/ingo-library/blob/master/autoload/ingo/avoidprompt.vim.
For reference: |
@petobens |
Awesome |
Fixes #166.