diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-12-18 19:18:47 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-18 19:18:47 -0800 |
commit | b42e0c40c8b8e906eccb14db0d0648a39e49c363 (patch) | |
tree | 870ee8ad792c40e9305359c9a6f1a27000cb9d65 /test/functional/autocmd/cursormoved_spec.lua | |
parent | 95803f0e902278079e5876082465b1910c819947 (diff) | |
download | rneovim-b42e0c40c8b8e906eccb14db0d0648a39e49c363.tar.gz rneovim-b42e0c40c8b8e906eccb14db0d0648a39e49c363.tar.bz2 rneovim-b42e0c40c8b8e906eccb14db0d0648a39e49c363.zip |
fix: update last cursor on first CursorMoved (#16698)
Closes https://github.com/neovim/neovim/issues/16625 https://github.com/neovim/neovim/issues/12923
The first defined CursorMoved autocommand will immediately
fire if the cursor has previously moved upon definition
of the autocommand.
Plugins add dummy autocommands such as:
```lua
autocmd CursorMoved * execute ''
```
to avoid this behavior.
Instead, when defining a new CursorHold autocommand, force
update the last cursor position.
See https://github.com/vim/vim/issues/2053
Diffstat (limited to 'test/functional/autocmd/cursormoved_spec.lua')
-rw-r--r-- | test/functional/autocmd/cursormoved_spec.lua | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/functional/autocmd/cursormoved_spec.lua b/test/functional/autocmd/cursormoved_spec.lua index d0f46e689b..9641d4b096 100644 --- a/test/functional/autocmd/cursormoved_spec.lua +++ b/test/functional/autocmd/cursormoved_spec.lua @@ -31,4 +31,12 @@ describe('CursorMoved', function() eq({'aaa'}, funcs.nvim_buf_get_lines(eval('g:buf'), 0, -1, true)) eq(0, eval('g:cursormoved')) end) + + it("is not triggered by cursor movement prior to first CursorMoved instantiation", function() + source([[ + let g:cursormoved = 0 + autocmd CursorMoved * let g:cursormoved += 1 + ]]) + eq(0, eval('g:cursormoved')) + end) end) |