From 9ce2c73180b741a7969ede940c3c439d0cc9010d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 26 Mar 2022 09:36:26 +0800 Subject: revert: "Fix redraw regression with w_p_cole in visual mode" Revert the code change from b7d6caaa036c3d1be716bb6e4b0f56c08fb8dcf5. The test is kept. The glitch was fixed by #17864, so this workaround is no longer needed. --- src/nvim/screen.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 67eee55c51..38ea861cbd 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -667,15 +667,11 @@ void conceal_check_cursor_line(void) /// Whether cursorline is drawn in a special way /// -/// If true, both old and new cursorline will need -/// to be redrawn when moving cursor within windows. -/// TODO(bfredl): VIsual_active shouldn't be needed, but is used to fix a glitch -/// caused by scrolling. +/// If true, both old and new cursorline will need to be redrawn when moving cursor within windows. bool win_cursorline_standout(const win_T *wp) FUNC_ATTR_NONNULL_ALL { - return wp->w_p_cul - || (wp->w_p_cole > 0 && (VIsual_active || !conceal_cursor_line(wp))); + return wp->w_p_cul || (wp->w_p_cole > 0 && !conceal_cursor_line(wp)); } /* -- cgit From 595c1a724af9fe93d4ff1df7d5c47e4c9c31a7a6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 28 Mar 2022 06:45:15 +0800 Subject: perf: only redraw concealed line if cursor has moved horizontally Building upon #17889, this moves conceal redrawing logic into move.c, so that concealed line is only redrawn if cursor has moved horizontally. --- src/nvim/edit.c | 8 -------- src/nvim/move.c | 13 ++++++++++--- src/nvim/normal.c | 7 ------- 3 files changed, 10 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/nvim/edit.c b/src/nvim/edit.c index c087948810..815d57121b 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1480,8 +1480,6 @@ bool edit(int cmdchar, bool startln, long count) /// @param ready not busy with something static void ins_redraw(bool ready) { - bool conceal_cursor_moved = false; - if (char_avail()) { return; } @@ -1504,7 +1502,6 @@ static void ins_redraw(bool ready) update_curswant(); ins_apply_autocmds(EVENT_CURSORMOVEDI); } - conceal_cursor_moved = true; curwin->w_last_cursormoved = curwin->w_cursor; } @@ -1560,11 +1557,6 @@ static void ins_redraw(bool ready) curbuf->b_changed_invalid = false; } - if (curwin->w_p_cole > 0 && conceal_cursor_line(curwin) - && conceal_cursor_moved) { - redrawWinline(curwin, curwin->w_cursor.lnum); - } - pum_check_clear(); if (must_redraw) { update_screen(0); diff --git a/src/nvim/move.c b/src/nvim/move.c index 9b35a7da0a..5e02e355bf 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -96,12 +96,12 @@ static void comp_botline(win_T *wp) } /// Redraw when w_cline_row changes and 'relativenumber' or 'cursorline' is set. +/// Also when concealing is on and 'concealcursor' is not active. void redraw_for_cursorline(win_T *wp) FUNC_ATTR_NONNULL_ALL { - if ((wp->w_p_rnu || win_cursorline_standout(wp)) - && (wp->w_valid & VALID_CROW) == 0 - && !pum_visible()) { + if ((wp->w_valid & VALID_CROW) == 0 && !pum_visible() + && (wp->w_p_rnu || win_cursorline_standout(wp))) { // win_line() will redraw the number column and cursorline only. redraw_later(wp, VALID); } @@ -109,6 +109,7 @@ void redraw_for_cursorline(win_T *wp) /// Redraw when w_virtcol changes and 'cursorcolumn' is set or 'cursorlineopt' /// contains "screenline". +/// Also when concealing is on and 'concealcursor' is active. static void redraw_for_cursorcolumn(win_T *wp) FUNC_ATTR_NONNULL_ALL { @@ -121,6 +122,12 @@ static void redraw_for_cursorcolumn(win_T *wp) redraw_later(wp, VALID); } } + // If the cursor moves horizontally when 'concealcursor' is active, then the + // current line needs to be redrawn in order to calculate the correct + // cursor position. + if ((wp->w_valid & VALID_VIRTCOL) == 0 && wp->w_p_cole > 0 && conceal_cursor_line(wp)) { + redrawWinline(wp, wp->w_cursor.lnum); + } } /* diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 6c7595d1a4..72e80952ff 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1288,13 +1288,6 @@ static void normal_redraw(NormalState *s) update_topline(curwin); validate_cursor(); - // If the cursor moves horizontally when 'concealcursor' is active, then the - // current line needs to be redrawn in order to calculate the correct - // cursor position. - if (curwin->w_p_cole > 0 && conceal_cursor_line(curwin)) { - redrawWinline(curwin, curwin->w_cursor.lnum); - } - if (VIsual_active) { update_curbuf(INVERTED); // update inverted part } else if (must_redraw) { -- cgit