changeset 18440:d6cb1e706fb7 v8.1.2214

patch 8.1.2214: too much is redrawn when 'cursorline' is set Commit: https://github.com/vim/vim/commit/11a58af66fa5c442f0a22c5d59beabf187ed4e89 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Oct 24 22:32:31 2019 +0200 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 https://github.com/vim/vim/issues/5079)
author Bram Moolenaar <Bram@vim.org>
date Thu, 24 Oct 2019 22:45:04 +0200
parents 1768dfc3a9f6
children 176f51ad4211
files src/change.c src/drawscreen.c src/main.c src/testdir/dumps/Test_Xcursorline_13.dump src/testdir/dumps/Test_Xcursorline_14.dump src/testdir/dumps/Test_Xcursorline_15.dump src/testdir/dumps/Test_Xcursorline_16.dump src/testdir/dumps/Test_Xcursorline_17.dump src/testdir/dumps/Test_Xcursorline_18.dump src/version.c
diffstat 10 files changed, 35 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/src/change.c
+++ b/src/change.c
@@ -609,16 +609,21 @@ changed_common(
 	    if (hasAnyFolding(wp))
 		set_topline(wp, wp->w_topline);
 #endif
-	    // Relative numbering may require updating more.  Cursor line
-	    // highlighting probably needs to be updated if it's below the
-	    // change (or is using screenline highlighting)
-	    if (wp->w_p_rnu
+	    // Relative numbering may require updating more.
+	    if (wp->w_p_rnu)
+		redraw_win_later(wp, SOME_VALID);
 #ifdef FEAT_SYN_HL
-		    || ((wp->w_p_cul && lnum <= wp->w_last_cursorline)
-			    || (wp->w_p_culopt_flags & CULOPT_SCRLINE))
+	    // Cursor line highlighting probably need to be updated with
+	    // "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 (xtra == 0)
+		    redraw_win_later(wp, VALID);
+		else if (lnum <= wp->w_last_cursorline)
+		    redraw_win_later(wp, SOME_VALID);
+	    }
 #endif
-		    )
-		redraw_win_later(wp, SOME_VALID);
 	}
     }
 
--- a/src/drawscreen.c
+++ b/src/drawscreen.c
@@ -2124,7 +2124,12 @@ win_update(win_T *wp)
 				|| (wp->w_match_head != NULL
 						    && buf->b_mod_xlines != 0)
 #endif
-				)))))
+				))))
+#ifdef FEAT_SYN_HL
+		|| (wp->w_p_cul && (lnum == wp->w_cursor.lnum
+					     || lnum == wp->w_last_cursorline))
+#endif
+				)
 	{
 #ifdef FEAT_SEARCH_EXTRA
 	    if (lnum == mod_top)
--- a/src/main.c
+++ b/src/main.c
@@ -1380,27 +1380,20 @@ main_loop(
 	    validate_cursor();
 
 #ifdef FEAT_SYN_HL
-	    if (curwin->w_p_cul && curwin->w_p_wrap
-				&& (curwin->w_p_culopt_flags & CULOPT_SCRLINE))
-		must_redraw = NOT_VALID;
+	    // Might need to update for 'cursorline'.
+	    // When 'cursorlineopt' is "screenline" need to redraw always.
+	    if (curwin->w_p_cul
+		    && (curwin->w_last_cursorline != curwin->w_cursor.lnum
+			|| (curwin->w_p_culopt_flags & CULOPT_SCRLINE))
+		    && !char_avail())
+		redraw_later(VALID);
 #endif
-
 	    if (VIsual_active)
 		update_curbuf(INVERTED); // update inverted part
 	    else if (must_redraw)
 	    {
 		mch_disable_flush();	// Stop issuing gui_mch_flush().
-#ifdef FEAT_SYN_HL
-		// Might need some more update for the cursorscreen line.
-		// TODO: can we optimize this?
-		if (curwin->w_p_cul
-			&& curwin->w_p_wrap
-			&& (curwin->w_p_culopt_flags & CULOPT_SCRLINE)
-			&& !char_avail())
-		    update_screen(VALID);
-		else
-#endif
-		    update_screen(0);
+		update_screen(0);
 		mch_enable_flush();
 	    }
 	    else if (redraw_cmdline || clear_cmdline)
--- a/src/testdir/dumps/Test_Xcursorline_13.dump
+++ b/src/testdir/dumps/Test_Xcursorline_13.dump
@@ -17,4 +17,4 @@
 | +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
 | +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
 |<+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
-|:+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
+| +0&&@74
--- a/src/testdir/dumps/Test_Xcursorline_14.dump
+++ b/src/testdir/dumps/Test_Xcursorline_14.dump
@@ -17,4 +17,4 @@
 | +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
 | +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
 |<+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
-|:+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
+| +0&&@74
--- a/src/testdir/dumps/Test_Xcursorline_15.dump
+++ b/src/testdir/dumps/Test_Xcursorline_15.dump
@@ -17,4 +17,4 @@
 | +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
 | +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
 |<+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
-|:+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
+| +0&&@74
--- a/src/testdir/dumps/Test_Xcursorline_16.dump
+++ b/src/testdir/dumps/Test_Xcursorline_16.dump
@@ -17,4 +17,4 @@
 | +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
 | +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
 |<+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
-|:+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
+| +0&&@74
--- a/src/testdir/dumps/Test_Xcursorline_17.dump
+++ b/src/testdir/dumps/Test_Xcursorline_17.dump
@@ -17,4 +17,4 @@
 | +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
 | +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
 |<+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
-|:+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
+| +0&&@74
--- a/src/testdir/dumps/Test_Xcursorline_18.dump
+++ b/src/testdir/dumps/Test_Xcursorline_18.dump
@@ -17,4 +17,4 @@
 | +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
 | +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
 |<+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
-|:+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
+| +0&&@74
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2214,
+/**/
     2213,
 /**/
     2212,