diff src/drawscreen.c @ 29050:a2710736125a v8.2.5047

patch 8.2.5047: CurSearch highlight is often wrong Commit: https://github.com/vim/vim/commit/368137aa525982984beed73940af481ac53a62af Author: Bram Moolenaar <Bram@vim.org> Date: Tue May 31 13:43:12 2022 +0100 patch 8.2.5047: CurSearch highlight is often wrong Problem: CurSearch highlight is often wrong. Solution: Remember the last highlighted position and redraw when needed.
author Bram Moolenaar <Bram@vim.org>
date Tue, 31 May 2022 14:45:03 +0200
parents d770568e6c98
children b90bca860b5a
line wrap: on
line diff
--- a/src/drawscreen.c
+++ b/src/drawscreen.c
@@ -1618,6 +1618,19 @@ win_update(win_T *wp)
 	    }
 #endif
 	}
+
+#ifdef FEAT_SEARCH_EXTRA
+	if (search_hl_has_cursor_lnum > 0)
+	{
+	    // CurSearch was used last time, need to redraw the line with it to
+	    // avoid having two matches highlighted with CurSearch.
+	    if (mod_top == 0 || mod_top > search_hl_has_cursor_lnum)
+		mod_top = search_hl_has_cursor_lnum;
+	    if (mod_bot == 0 || mod_bot < search_hl_has_cursor_lnum + 1)
+		mod_bot = search_hl_has_cursor_lnum + 1;
+	}
+#endif
+
 #ifdef FEAT_FOLDING
 	if (mod_top != 0 && hasAnyFolding(wp))
 	{
@@ -1684,6 +1697,10 @@ win_update(win_T *wp)
     }
     wp->w_redraw_top = 0;	// reset for next time
     wp->w_redraw_bot = 0;
+#ifdef FEAT_SEARCH_EXTRA
+    search_hl_has_cursor_lnum = 0;
+#endif
+
 
     // When only displaying the lines at the top, set top_end.  Used when
     // window has scrolled down for msg_scrolled.