mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 06:28:35 +00:00
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
This commit is contained in:

committed by
GitHub

parent
95803f0e90
commit
b42e0c40c8
@@ -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;
|
||||
|
Reference in New Issue
Block a user