diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-02-08 11:34:55 +0100 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-02-08 11:34:55 +0100 |
commit | 7ce34c9a947b17a8b5e81e7c2335a63552182d10 (patch) | |
tree | 5b1667c46abd1b0a603fb9d66ea4eefbcd56f856 /src/change.c | |
parent | b8170143c8f8a115b5be59a94d10f931d3cd567c (diff) |
patch 9.1.0082: Redrawing can be improved when deleting lines with 'cursorline'v9.1.0082
Problem: Redrawing can be improved when deleting lines with 'cursorline'.
Solution: Use smarter invalidation and adjustment. Remove unnecessary
UPD_VALID as it is already set at the top of the loop. Make
the test for #4862 fail without the fix.
(zeertzjq)
closes: #13986
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/change.c')
-rw-r--r-- | src/change.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/change.c b/src/change.c index c0b8785ba1..0ea424f989 100644 --- a/src/change.c +++ b/src/change.c @@ -656,22 +656,20 @@ changed_common( set_topline(wp, wp->w_topline); #endif // If lines have been added or removed, relative numbering always - // requires a redraw. + // requires an update even if cursor didn't move. if (wp->w_p_rnu && xtra != 0) - { wp->w_last_cursor_lnum_rnu = 0; - redraw_win_later(wp, UPD_VALID); - } + #ifdef FEAT_SYN_HL - // Cursor line highlighting probably need to be updated with - // "UPD_VALID" if it's below the change. - // If the cursor line is inside the change we need to redraw more. - if (wp->w_p_cul) + if (wp->w_p_cul && wp->w_last_cursorline >= lnum) { - if (xtra == 0) - redraw_win_later(wp, UPD_VALID); - else if (lnum <= wp->w_last_cursorline) - redraw_win_later(wp, UPD_SOME_VALID); + if (wp->w_last_cursorline < lnume) + // If 'cursorline' was inside the change, it has already + // been invalidated in w_lines[] by the loop above. + wp->w_last_cursorline = 0; + else + // If 'cursorline' was below the change, adjust its lnum. + wp->w_last_cursorline += xtra; } #endif } |