Skip to content

s:dispatch: shorten displayed message to avoid hit-enter prompt#167

Merged
tpope merged 6 commits intotpope:masterfrom
blueyed:avoid-hit-enter-in-dispatch
Jul 26, 2019
Merged

s:dispatch: shorten displayed message to avoid hit-enter prompt#167
tpope merged 6 commits intotpope:masterfrom
blueyed:avoid-hit-enter-in-dispatch

Conversation

@blueyed
Copy link
Copy Markdown
Contributor

@blueyed blueyed commented Mar 25, 2016

Fixes #166.

@blueyed
Copy link
Copy Markdown
Contributor Author

blueyed commented Sep 15, 2016

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 -12).

Comment thread 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?!
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blueyed
Copy link
Copy Markdown
Contributor Author

blueyed commented Sep 15, 2016

This should also be done in dispatch#complete then.

@blueyed
Copy link
Copy Markdown
Contributor Author

blueyed commented Sep 15, 2016

What about the suggestion from #166 (comment):

A shorter/simpler approach would be to just call :redraw after the :echom (instead of :echo).

This would display it normally, but skip it in case there would have been a hit-enter prompt.
The benefit here would be that it's in :mess, in case you want to get to it later.

@petobens
Copy link
Copy Markdown

petobens commented Apr 7, 2019

Hi @tpope and @blueyed; I just bumped into this issue and was wondering if there is a chance to move this pr forward (with the corresponding necessary changes). Thanks in advance!

@simlei
Copy link
Copy Markdown

simlei commented Apr 17, 2019

Would love to see this PR or a similar change in vim-dispatch.

@blueyed
Copy link
Copy Markdown
Contributor Author

blueyed commented Jul 24, 2019

Rebased (old head: 0722f74).

@blueyed blueyed force-pushed the avoid-hit-enter-in-dispatch branch from 9ed7d5e to bc6e0af Compare July 24, 2019 23:58
Comment thread 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
Copy link
Copy Markdown
Owner

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?

Comment thread 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] . '…'
Copy link
Copy Markdown
Owner

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).

@blueyed
Copy link
Copy Markdown
Contributor Author

blueyed commented Jul 25, 2019

Maybe this explains the 12/13 discrepancy?

No.
But with Vim I only need -2 (which makes more sense)! (I was using Neovim apparently already when reporting the issue in 2016)
This is the case with Vim 7.4.2200 already (the oldest to really support async (#283)).
But have checked it using echo repeat('X', &columns-1) back to Vim 7.4.41.

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.

@blueyed
Copy link
Copy Markdown
Contributor Author

blueyed commented Jul 25, 2019

The difference is due to (not) using set showcmd etc.
Something like this would be useful: https://github.com/Shougo/unite.vim/blob/e1d3bb9f836a8645807b790345b69666bf22bb2f/autoload/unite/view.vim#L799-L826

@blueyed
Copy link
Copy Markdown
Contributor Author

blueyed commented Jul 25, 2019

Even with (re)setting showcmd it will overwrite the tail when (re)setting it.
I've filed an issue for Vim itself: vim/vim#4732.

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.

Comment thread autoload/dispatch.vim
@tpope tpope merged commit b10d68a into tpope:master Jul 26, 2019
@blueyed blueyed deleted the avoid-hit-enter-in-dispatch branch July 26, 2019 19:27
@blueyed
Copy link
Copy Markdown
Contributor Author

blueyed commented Aug 28, 2019

For reference: v:echospace was added in Vim patch 8.1.1913 (vim/vim@37f4cbd).

@petobens
Copy link
Copy Markdown

@blueyed will that allow to close #166?

@blueyed
Copy link
Copy Markdown
Contributor Author

blueyed commented Sep 24, 2019

@petobens
Yes, it's meant to help with that.

@petobens
Copy link
Copy Markdown

Awesome

blueyed added a commit to blueyed/vim-dispatch that referenced this pull request Oct 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Displaying the executed command might cause hit-Enter prompt

4 participants