aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/edit.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-08-12 09:50:17 +0800
committerGitHub <noreply@github.com>2023-08-12 09:50:17 +0800
commit58a1ef8e6a93c615379f6fbe7234697bcdc42b3e (patch)
treec15b5ac2889ceacf923cca47b2954ab291c9dadf /src/nvim/edit.c
parent6c07a189f2d10a533af8a51819ea96c45e0c567e (diff)
downloadrneovim-58a1ef8e6a93c615379f6fbe7234697bcdc42b3e.tar.gz
rneovim-58a1ef8e6a93c615379f6fbe7234697bcdc42b3e.tar.bz2
rneovim-58a1ef8e6a93c615379f6fbe7234697bcdc42b3e.zip
fix(events): avoid unnecessary CursorMoved (#24675)
Problem: Temporarily changing current window in a script causes CursorMoved to be triggerd. Solution: Don't trigger CursorMoved if neither curwin nor cursor changed between two checks.
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r--src/nvim/edit.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index e44c49ad0b..b8d2eca810 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -1287,7 +1287,8 @@ void ins_redraw(bool ready)
// Trigger CursorMoved if the cursor moved. Not when the popup menu is
// visible, the command might delete it.
if (ready && has_event(EVENT_CURSORMOVEDI)
- && !equalpos(curwin->w_last_cursormoved, curwin->w_cursor)
+ && (last_cursormoved_win != curwin
+ || !equalpos(last_cursormoved, curwin->w_cursor))
&& !pum_visible()) {
// Need to update the screen first, to make sure syntax
// highlighting is correct after making a change (e.g., inserting
@@ -1300,7 +1301,8 @@ void ins_redraw(bool ready)
// getcurpos()
update_curswant();
ins_apply_autocmds(EVENT_CURSORMOVEDI);
- curwin->w_last_cursormoved = curwin->w_cursor;
+ last_cursormoved_win = curwin;
+ last_cursormoved = curwin->w_cursor;
}
// Trigger TextChangedI if changedtick differs.