[vim/vim] Out-of-order execution about `eventignore` and `CursorMoved`. (#8641)

25 views
Skip to first unread message

AnnoyingUserName

unread,
Jul 26, 2021, 4:07:58 AM7/26/21
to vim/vim, Subscribed

Describe the bug
Cursor has been moved before executed set ei=, but autocommand CursorMoved still been executed.

To Reproduce
Detailed steps to reproduce the behavior:

  1. Run vim --clean (or gvim --clean, etc.)
  2. Open any window with some contents like :help.
  3. Import time :py3 import time.
  4. Set a autocommand :autocmd CursorMoved * echom 'autocmd: ei = ' . &ei . ', line = ' line('.') . ',time = ' . py3eval('str(time.time())').
  5. Define a python function
:py3 << EOF
import vim
def Fun():
  vim.command('set ei=all')
  vim.command('100')  #  move to line 100
  vim.command('200')  #  move to line 200
  vim.command(f'echom "set ei: ei = " . &ei . ", line = " . line(".") . ", time = " . "{time.time()}"')
  vim.command('set ei=')
EOF
  1. Call python funciton :py3 Fun().
  2. Use :messages, and you can find CursorMoved has been executed after set ei=.

Environment (please complete the following information):

  • Vim version IMproved 8.2 (2019 Dec 12)
  • OS: Ubuntu 18.04.5


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Bram Moolenaar

unread,
Jul 27, 2021, 10:01:40 AM7/27/21
to vim/vim, Subscribed


> **Describe the bug**
> Cursor has been moved before executed `set ei=`, but autocommand `CursorMoved` still been executed.
>
> **To Reproduce**

> Detailed steps to reproduce the behavior:
> 1. Run `vim --clean` (or `gvim --clean`, etc.)
> 2. Open any window with some contents like `:help`.
> 3. Import time `:py3 import time`.
> 4. Set a autocommand `:autocmd CursorMoved * echom 'autocmd: ei = ' . &ei . ', line = ' line('.') . ',time = ' . py3eval('str(time.time())')`.
> 5. Define a python function

> ```
> :py3 << EOF
> import vim
> def Fun():
> vim.command('set ei=all')
> vim.command('100') # move to line 100
> vim.command('200') # move to line 200
> vim.command(f'echom "set ei: ei = " . &ei . ", line = " . line(".") . ", time = " . "{time.time()}"')
> vim.command('set ei=')
> EOF
> ```
> 6. Call python funciton `:py3 Fun()`.
> 7. Use `:messages`, and you can find `CursorMoved` has been executed after `set ei=`.
>
> **Environment (please complete the following information):**
> - Vim version IMproved 8.2 (2019 Dec 12)
> - OS: Ubuntu 18.04.5

This happens because the CursorMoved event is triggered in the main
loop, after any commands have finished executing.

I don't think there currently is a trick to avoid this, other than
putting the cursor back where it was. We could perhaps add something,
but it would defeat plugins that do expect to get the CursorMoved event.

--
Hear about the guy who played a blank tape at full blast?
The mime next door went nuts.

/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Yggdroot

unread,
1:41 AM (12 hours ago) 1:41 AM
to vim/vim, Subscribed
Yggdroot left a comment (vim/vim#8641)

Neovim does not have this bug.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/8641/3695597253@github.com>

Reply all
Reply to author
Forward
0 new messages