Skip to content

Commit 11a58af

Browse files
committed
patch 8.1.2214: too much is redrawn when 'cursorline' is set
Problem: Too much is redrawn when 'cursorline' is set. Solution: Don't do a complete redraw. (closes #5079)
1 parent aa1f04d commit 11a58af

10 files changed

Lines changed: 35 additions & 30 deletions

src/change.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -609,16 +609,21 @@ changed_common(
609609
if (hasAnyFolding(wp))
610610
set_topline(wp, wp->w_topline);
611611
#endif
612-
// Relative numbering may require updating more. Cursor line
613-
// highlighting probably needs to be updated if it's below the
614-
// change (or is using screenline highlighting)
615-
if (wp->w_p_rnu
612+
// Relative numbering may require updating more.
613+
if (wp->w_p_rnu)
614+
redraw_win_later(wp, SOME_VALID);
616615
#ifdef FEAT_SYN_HL
617-
|| ((wp->w_p_cul && lnum <= wp->w_last_cursorline)
618-
|| (wp->w_p_culopt_flags & CULOPT_SCRLINE))
616+
// Cursor line highlighting probably need to be updated with
617+
// "VALID" if it's below the change.
618+
// If the cursor line is inside the change we need to redraw more.
619+
if (wp->w_p_cul)
620+
{
621+
if (xtra == 0)
622+
redraw_win_later(wp, VALID);
623+
else if (lnum <= wp->w_last_cursorline)
624+
redraw_win_later(wp, SOME_VALID);
625+
}
619626
#endif
620-
)
621-
redraw_win_later(wp, SOME_VALID);
622627
}
623628
}
624629

src/drawscreen.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2124,7 +2124,12 @@ win_update(win_T *wp)
21242124
|| (wp->w_match_head != NULL
21252125
&& buf->b_mod_xlines != 0)
21262126
#endif
2127-
)))))
2127+
))))
2128+
#ifdef FEAT_SYN_HL
2129+
|| (wp->w_p_cul && (lnum == wp->w_cursor.lnum
2130+
|| lnum == wp->w_last_cursorline))
2131+
#endif
2132+
)
21282133
{
21292134
#ifdef FEAT_SEARCH_EXTRA
21302135
if (lnum == mod_top)

src/main.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,27 +1380,20 @@ main_loop(
13801380
validate_cursor();
13811381

13821382
#ifdef FEAT_SYN_HL
1383-
if (curwin->w_p_cul && curwin->w_p_wrap
1384-
&& (curwin->w_p_culopt_flags & CULOPT_SCRLINE))
1385-
must_redraw = NOT_VALID;
1383+
// Might need to update for 'cursorline'.
1384+
// When 'cursorlineopt' is "screenline" need to redraw always.
1385+
if (curwin->w_p_cul
1386+
&& (curwin->w_last_cursorline != curwin->w_cursor.lnum
1387+
|| (curwin->w_p_culopt_flags & CULOPT_SCRLINE))
1388+
&& !char_avail())
1389+
redraw_later(VALID);
13861390
#endif
1387-
13881391
if (VIsual_active)
13891392
update_curbuf(INVERTED); // update inverted part
13901393
else if (must_redraw)
13911394
{
13921395
mch_disable_flush(); // Stop issuing gui_mch_flush().
1393-
#ifdef FEAT_SYN_HL
1394-
// Might need some more update for the cursorscreen line.
1395-
// TODO: can we optimize this?
1396-
if (curwin->w_p_cul
1397-
&& curwin->w_p_wrap
1398-
&& (curwin->w_p_culopt_flags & CULOPT_SCRLINE)
1399-
&& !char_avail())
1400-
update_screen(VALID);
1401-
else
1402-
#endif
1403-
update_screen(0);
1396+
update_screen(0);
14041397
mch_enable_flush();
14051398
}
14061399
else if (redraw_cmdline || clear_cmdline)

src/testdir/dumps/Test_Xcursorline_13.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
| +0#0000e05#a8a8a8255@3| +0#af5f00255#ffffff0@3|>+0#4040ff13&|i+0#0000000&|n|s|-+0#0000e05&|z+0#0000000&|w|e|i|-+0#0000e05&|d+0#0000000&|r|e|i|-+0#0000e05&|v+0#0000000&|i||+1&&|~+0#4040ff13&| @47
1818
| +0#0000e05#a8a8a8255@3| +0#af5f00255#ffffff0@3|>+0#4040ff13&|e+0#0000000&|r|-+0#0000e05&|f+0#0000000&|ü|n|f|-+0#0000e05&|s+0#0000000&|e|c|h|s|@+0#4040ff13&@2||+1#0000000&|~+0#4040ff13&| @47
1919
|<+3#0000000&|o| |N|a|m|e|]| |[|+|]| |1|,|1| @5|T|o|p| |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @17|5|,|0|-|1| @9|B|o|t
20-
|:+0&&|s|e|t| |b|r|e|a|k|i|n|d|e|n|t| |f|o|l|d|c|o|l|u|m|n|=|2| |s|i|g|n|c|o|l|u|m|n|=|y|e|s| @30
20+
| +0&&@74

src/testdir/dumps/Test_Xcursorline_14.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
| +0#0000e05#a8a8a8255@3| +0#af5f00255#ffffff0@3|>+0#4040ff13&|i+0#0000000&|n|s|-+0#0000e05&|z+0#0000000&|w|e|i|-+0#0000e05&|d+0#0000000&|r|e|i|-+0#0000e05&|v+0#0000000&|i||+1&&|~+0#4040ff13&| @47
1818
| +0#0000e05#a8a8a8255@3| +0#af5f00255#ffffff0@3|>+0#4040ff13&|e+0#0000000&|r|-+0#0000e05&|f+0#0000000&|ü|n|f|-+0#0000e05&|s+0#0000000&|e|c|h|s|@+0#4040ff13&@2||+1#0000000&|~+0#4040ff13&| @47
1919
|<+3#0000000&|o| |N|a|m|e|]| |[|+|]| |1|,|2|6|-|3|0| @1|T|o|p| |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @17|5|,|0|-|1| @9|B|o|t
20-
|:+0&&|s|e|t| |b|r|e|a|k|i|n|d|e|n|t| |f|o|l|d|c|o|l|u|m|n|=|2| |s|i|g|n|c|o|l|u|m|n|=|y|e|s| @30
20+
| +0&&@74

src/testdir/dumps/Test_Xcursorline_15.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
| +0#0000e05#a8a8a8255@3| +0#af5f00255#ffffff0@3|>+0#4040ff13&|i+0#0000000&|n|s|-+0#0000e05&|z+0#0000000&|w|e|i|-+0#0000e05&|d+0#0000000&|r|e|i|-+0#0000e05&|v+0#0000000&|i||+1&&|~+0#4040ff13&| @47
1818
| +0#0000e05#a8a8a8255@3| +0#af5f00255#ffffff0@3|>+0#4040ff13&|e+0#0000000&|r|-+0#0000e05&|f+0#0000000&|ü|n|f|-+0#0000e05&|s+0#0000000&|e|c|h|s|@+0#4040ff13&@2||+1#0000000&|~+0#4040ff13&| @47
1919
|<+3#0000000&|o| |N|a|m|e|]| |[|+|]| |1|,|4|3|-|4|7| @1|T|o|p| |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @17|5|,|0|-|1| @9|B|o|t
20-
|:+0&&|s|e|t| |b|r|e|a|k|i|n|d|e|n|t| |f|o|l|d|c|o|l|u|m|n|=|2| |s|i|g|n|c|o|l|u|m|n|=|y|e|s| @30
20+
| +0&&@74

src/testdir/dumps/Test_Xcursorline_16.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
| +0#0000e05#a8a8a8255@3| +0#af5f00255#ffffff0@3|>+0#4040ff13&|i+0#0000000&|n|s|-+0#0000e05&|z+0#0000000&|w|e|i|-+0#0000e05&|d+0#0000000&|r|e|i|-+0#0000e05&|v+0#0000000&|i||+1&&|~+0#4040ff13&| @47
1818
| +0#0000e05#a8a8a8255@3| +0#af5f00255#ffffff0@3|>+0#4040ff13&|e+0#0000000&|r|-+0#0000e05&|f+0#0000000&|ü|n|f|-+0#0000e05&|s+0#0000000&|e|c|h|s|@+0#4040ff13&@2||+1#0000000&|~+0#4040ff13&| @47
1919
|<+3#0000000&|o| |N|a|m|e|]| |[|+|]| |1|,|5|9|-|6|4| @1|T|o|p| |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @17|5|,|0|-|1| @9|B|o|t
20-
|:+0&&|s|e|t| |b|r|e|a|k|i|n|d|e|n|t| |f|o|l|d|c|o|l|u|m|n|=|2| |s|i|g|n|c|o|l|u|m|n|=|y|e|s| @30
20+
| +0&&@74

src/testdir/dumps/Test_Xcursorline_17.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
| +0#0000e05#a8a8a8255@3| +0#af5f00255#ffffff0@3|>+0#4040ff13&|i+0#0000000&|n|s|-+0#0000e05&|z+0#0000000&|w|e|i|-+0#0000e05&|d+0#0000000&|r|e|i|-+0#0000e05&|v+0#0000000&|i||+1&&|~+0#4040ff13&| @47
1818
| +0#0000e05#a8a8a8255@3| +0#af5f00255#ffffff0@3|>+0#4040ff13&|e+0#0000000&|r|-+0#0000e05&|f+0#0000000&|ü|n|f|-+0#0000e05&|s+0#0000000&|e|c|h|s|@+0#4040ff13&@2||+1#0000000&|~+0#4040ff13&| @47
1919
|<+3#0000000&|o| |N|a|m|e|]| |[|+|]| |1|,|7|5|-|8|1| @1|T|o|p| |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @17|5|,|0|-|1| @9|B|o|t
20-
|:+0&&|s|e|t| |b|r|e|a|k|i|n|d|e|n|t| |f|o|l|d|c|o|l|u|m|n|=|2| |s|i|g|n|c|o|l|u|m|n|=|y|e|s| @30
20+
| +0&&@74

src/testdir/dumps/Test_Xcursorline_18.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
| +0#0000e05#a8a8a8255@3| +0#af5f00255#ffffff0@3|>+0#4040ff13&|i+0#0000000&|n|s|-+0#0000e05&|z+0#0000000&|w|e|i|-+0#0000e05&|d+0#0000000&|r|e|i|-+0#0000e05&|v+0#0000000&|i||+1&&|~+0#4040ff13&| @47
1818
| +0#0000e05#a8a8a8255@3| +0#af5f00255#ffffff0@3|>+0#4040ff13&|e+0#0000000&|r|-+0#0000e05&|f+0#0000000&|ü|n|f|-+0#0000e05&|s+0#0000000&|e|c|h|s|@+0#4040ff13&@2||+1#0000000&|~+0#4040ff13&| @47
1919
|<+3#0000000&|o| |N|a|m|e|]| |[|+|]| |1|,|9|1|-|9|8| @1|T|o|p| |[+1&&|N|o| |N|a|m|e|]| |[|+|]| @17|5|,|0|-|1| @9|B|o|t
20-
|:+0&&|s|e|t| |b|r|e|a|k|i|n|d|e|n|t| |f|o|l|d|c|o|l|u|m|n|=|2| |s|i|g|n|c|o|l|u|m|n|=|y|e|s| @30
20+
| +0&&@74

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
2214,
744746
/**/
745747
2213,
746748
/**/

0 commit comments

Comments
 (0)