aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2021-12-18 19:18:47 -0800
committerGitHub <noreply@github.com>2021-12-18 19:18:47 -0800
commitb42e0c40c8b8e906eccb14db0d0648a39e49c363 (patch)
tree870ee8ad792c40e9305359c9a6f1a27000cb9d65 /src
parent95803f0e902278079e5876082465b1910c819947 (diff)
downloadrneovim-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 'src')
-rw-r--r--src/nvim/autocmd.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index 3780cad1d6..463bd5e0e6 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -932,6 +932,12 @@ static int do_autocmd_event(event_T event, char_u *pat, bool once, int nested, c
last_mode = get_mode();
}
+ // If the event is CursorMoved, update the last cursor position
+ // position to avoid immediately triggering the autocommand
+ if (event == EVENT_CURSORMOVED && !has_event(EVENT_CURSORMOVED)) {
+ curwin->w_last_cursormoved = curwin->w_cursor;
+ }
+
ap->cmds = NULL;
*prev_ap = ap;
last_autopat[(int)event] = ap;