cursormoved: make global last_cursormoved window-local

Fixes https://github.com/neovim/neovim/issues/9755
This commit is contained in:
Marco Hinz 2019-03-28 20:49:19 +01:00
parent f6fb370b1b
commit 357f95a77e
No known key found for this signature in database
GPG Key ID: 1C980A1B657B4A4F
5 changed files with 6 additions and 7 deletions

View File

@ -1035,6 +1035,7 @@ struct window_S {
// current virtual column // current virtual column
linenr_T w_last_cursorline; ///< where last 'cursorline' was drawn linenr_T w_last_cursorline; ///< where last 'cursorline' was drawn
pos_T w_last_cursormoved; ///< for CursorMoved event
// the next seven are used to update the visual part // the next seven are used to update the visual part
char w_old_visual_mode; ///< last known VIsual_mode char w_old_visual_mode; ///< last known VIsual_mode

View File

@ -1376,7 +1376,7 @@ ins_redraw (
// Trigger CursorMoved if the cursor moved. Not when the popup menu is // Trigger CursorMoved if the cursor moved. Not when the popup menu is
// visible, the command might delete it. // visible, the command might delete it.
if (ready && (has_event(EVENT_CURSORMOVEDI) || curwin->w_p_cole > 0) if (ready && (has_event(EVENT_CURSORMOVEDI) || curwin->w_p_cole > 0)
&& !equalpos(last_cursormoved, curwin->w_cursor) && !equalpos(curwin->w_last_cursormoved, curwin->w_cursor)
&& !pum_visible()) { && !pum_visible()) {
// Need to update the screen first, to make sure syntax // Need to update the screen first, to make sure syntax
// highlighting is correct after making a change (e.g., inserting // highlighting is correct after making a change (e.g., inserting
@ -1392,7 +1392,7 @@ ins_redraw (
ins_apply_autocmds(EVENT_CURSORMOVEDI); ins_apply_autocmds(EVENT_CURSORMOVEDI);
} }
conceal_cursor_moved = true; conceal_cursor_moved = true;
last_cursormoved = curwin->w_cursor; curwin->w_last_cursormoved = curwin->w_cursor;
} }
// Trigger TextChangedI if changedtick differs. // Trigger TextChangedI if changedtick differs.

View File

@ -788,8 +788,6 @@ EXTERN char_u *autocmd_fname INIT(= NULL); // fname for <afile> on cmdline
EXTERN int autocmd_bufnr INIT(= 0); // fnum for <abuf> on cmdline EXTERN int autocmd_bufnr INIT(= 0); // fnum for <abuf> on cmdline
EXTERN char_u *autocmd_match INIT(= NULL); // name for <amatch> on cmdline EXTERN char_u *autocmd_match INIT(= NULL); // name for <amatch> on cmdline
EXTERN int did_cursorhold INIT(= false); // set when CursorHold t'gerd EXTERN int did_cursorhold INIT(= false); // set when CursorHold t'gerd
// for CursorMoved event
EXTERN pos_T last_cursormoved INIT(= { 0, 0, 0 });
EXTERN int postponed_split INIT(= 0); /* for CTRL-W CTRL-] command */ EXTERN int postponed_split INIT(= 0); /* for CTRL-W CTRL-] command */
EXTERN int postponed_split_flags INIT(= 0); /* args for win_split() */ EXTERN int postponed_split_flags INIT(= 0); /* args for win_split() */

View File

@ -2175,7 +2175,7 @@ static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume, long xtra
/* when the cursor line is changed always trigger CursorMoved */ /* when the cursor line is changed always trigger CursorMoved */
if (lnum <= curwin->w_cursor.lnum if (lnum <= curwin->w_cursor.lnum
&& lnume + (xtra < 0 ? -xtra : xtra) > curwin->w_cursor.lnum) && lnume + (xtra < 0 ? -xtra : xtra) > curwin->w_cursor.lnum)
last_cursormoved.lnum = 0; curwin->w_last_cursormoved.lnum = 0;
} }
/* /*

View File

@ -1187,12 +1187,12 @@ static void normal_check_cursor_moved(NormalState *s)
{ {
// Trigger CursorMoved if the cursor moved. // Trigger CursorMoved if the cursor moved.
if (!finish_op && (has_event(EVENT_CURSORMOVED) || curwin->w_p_cole > 0) if (!finish_op && (has_event(EVENT_CURSORMOVED) || curwin->w_p_cole > 0)
&& !equalpos(last_cursormoved, curwin->w_cursor)) { && !equalpos(curwin->w_last_cursormoved, curwin->w_cursor)) {
if (has_event(EVENT_CURSORMOVED)) { if (has_event(EVENT_CURSORMOVED)) {
apply_autocmds(EVENT_CURSORMOVED, NULL, NULL, false, curbuf); apply_autocmds(EVENT_CURSORMOVED, NULL, NULL, false, curbuf);
} }
last_cursormoved = curwin->w_cursor; curwin->w_last_cursormoved = curwin->w_cursor;
} }
} }