-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
CmdLineEnter, CmdLineLeave are triggered from mappings #2889
Comments
What if the user has a map like |
Justin M Keyes wrote:
# Actual behavior:
```
:au CmdLineEnter * echom localtime()
:nnoremap a :<CR>
```
Then typing `a` will trigger the CmdLineEnter handler.
# Expected behavior:
Given that CmdLineEnter, CmdLineLeave are mostly for interactive use-cases, it seems like an oversight to also invoke them from mappings. Also based on `:help CmdLineEnter`.
Could check `KeyTyped`:
That becomes too unpredictable. Users may map some keys, use them as
shortcuts.
However, when the whole command is generated, the user is never prompted
to type anything, I suppose the autocommands are not useful. So perhaps
triggering could be postponed until waiting for a character to be typed?
Not sure what the actual problem is we are trying to fix here.
…--
It's not hard to meet expenses, they're everywhere.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
It's a potential performance problem: However, I just noticed that InsertCharPre works the same way.
I'll leave it up to discussion whether to close this. |
What would happen if mapping exits command line immediately without waiting for typed character? Would Events can already be postponed until waiting for a character with the help of timers. function! s:do_domething() abort
echom localtime()
endfunction
au vimrc CmdlineEnter : let s:do = timer_start(0, {-> s:do_domething()})
au vimrc CmdlineLeave : call timer_stop(s:do) |
That doesn't solve the problem at all, it just creates more problems for plugin authors. If timers were a solution we wouldn't have needed |
> Not sure what the actual problem is we are trying to fix here.
If you have an autocmd which temporarily enables `'relativenumber'` while you're on the command-line, maybe to help you write a range:
augroup my_cmdline
autocmd!
autocmd CmdlineEnter : setlocal relativenumber number | redraw
autocmd CmdlineLeave : setlocal norelativenumber nonumber
augroup END
It may be triggered when the command-line is entered from a mapping or an autocmd, which is distracting if you disable `'relativenumber'` by default. Because it makes the column number appear and disappear immediately afterwards, when you don't expect it (i.e. press a mapping which executes an Ex command for example).
It sometimes does on my machine if I install the previous autocmd, but I don't know exactly which mappings or other autocmds are interacting.
> So perhaps triggering could be postponed until waiting for a character to be typed?
+1. I would like that change.
For your example it would work well to postpone CmdlineEnter until
starting to wait for a character.
I assume CmdlineChanged would only be triggered after CmdlineEnter.
Although these changes seem like a good idea, I wonder if anything would
break. Some plugin that depends on the autocmd events even when the
user is not typing the cmdline?
…--
ARTHUR: Ni!
BEDEVERE: Nu!
ARTHUR: No. Ni! More like this. "Ni"!
BEDEVERE: Ni, ni, ni!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
I was trying to use this autocmd to check if the user left the command line without typing anything.
and somewhere else:
and the event wouldn't trigger at all if the setting is off. |
- develop.txt is for design/guidelines; architecture/concepts should live elsewhere (currently src/nvim/README.md) - move dev-jargon to intro.txt - replace https://neovim.io/community (deprecated) with https://neovim.io/#chat - <Cmd> avoids CmdlineEnter/Leave vim/vim#2889
- develop.txt is for design/guidelines; architecture/concepts should live elsewhere (currently src/nvim/README.md) - move dev-jargon to intro.txt - replace https://neovim.io/community (deprecated) with https://neovim.io/#chat - <Cmd> avoids CmdlineEnter/Leave vim/vim#2889
- develop.txt is for design/guidelines; architecture/concepts should live elsewhere (currently src/nvim/README.md) - move dev-jargon to intro.txt - replace https://neovim.io/community (deprecated) with https://neovim.io/#chat - <Cmd> avoids CmdlineEnter/Leave vim/vim#2889
Now that we have the pseudo-key |
Actual behavior:
Then typing
a
will trigger the CmdLineEnter handler.Expected behavior:
Given that CmdLineEnter, CmdLineLeave are mostly for interactive use-cases, it seems like an oversight to also invoke them from mappings. Also based on
:help CmdLineEnter
.Could check
KeyTyped
:The text was updated successfully, but these errors were encountered: