s:dispatch: shorten displayed message to avoid hit-enter prompt#167
s:dispatch: shorten displayed message to avoid hit-enter prompt#167tpope merged 6 commits intotpope:masterfrom
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 |
| 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.
|
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
| " 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.
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?
| " 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.
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.