Problem: CurSearch highlight is often wrong.
Solution: Remember the last highlighted position and redraw when needed.
}
#endif
}
+#ifdef FEAT_SEARCH_EXTRA
+ if (wp == curwin && xtra != 0 && search_hl_has_cursor_lnum >= lnum)
+ search_hl_has_cursor_lnum += xtra;
+#endif
}
// Call update_screen() later, which checks out what needs to be redrawn,
}
#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))
{
}
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.
EXTERN int screen_cur_col INIT(= 0);
#ifdef FEAT_SEARCH_EXTRA
-EXTERN match_T screen_search_hl; // used for 'hlsearch' highlight matching
+// used for 'hlsearch' highlight matching
+EXTERN match_T screen_search_hl;
+
+// last lnum where CurSearch was displayed
+EXTERN linenr_T search_hl_has_cursor_lnum INIT(= 0);
+
+// don't use 'hlsearch' temporarily
+EXTERN int no_hlsearch INIT(= FALSE);
#endif
#ifdef FEAT_FOLDING
EXTERN int stl_syntax INIT(= 0);
#endif
-#ifdef FEAT_SEARCH_EXTRA
-// don't use 'hlsearch' temporarily
-EXTERN int no_hlsearch INIT(= FALSE);
-#endif
-
#if defined(FEAT_BEVAL) && !defined(NO_X11_INCLUDES)
EXTERN BalloonEval *balloonEval INIT(= NULL);
EXTERN int balloonEvalForTerm INIT(= FALSE);
// Highlight the match were the cursor is using the CurSearch
// group.
if (shl == search_hl && shl->has_cursor)
+ {
shl->attr_cur = HL_ATTR(HLF_LC);
+ if (shl->attr_cur != shl->attr)
+ search_hl_has_cursor_lnum = lnum;
+ }
}
else if (col == shl->endcol)
--- /dev/null
+|-+0&#ffffff0@2| @56
+|a+0&#ffff4012|b|c|d|e+0&#ffffff0|f|g| @52
+>a+0࿈ff13|b|c|d|e+0&#ffffff0|f|g| @52
+|h|i|j|k|l| @54
+|-@2| @56
+|a+0&#ffff4012|b|c|d|e+0&#ffffff0|f|g| @52
+|h|i|j|k|l| @54
+|~+0#4040ff13&| @58
+| +0#0000000&@41|3|,|1| @10|A|l@1|
call term_sendkeys(buf, "h\<C-L>")
call VerifyScreenDump(buf, 'Test_hlsearch_cursearch_multiple_line_5', {})
+ " check clearing CurSearch when using it for another match
+ call term_sendkeys(buf, "G?^abcd\<CR>Y")
+ call term_sendkeys(buf, "kkP")
+ call VerifyScreenDump(buf, 'Test_hlsearch_cursearch_changed_1', {})
+
call StopVimInTerminal(buf)
call delete('Xhlsearch_cursearch')
endfunc
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 5047,
/**/
5046,
/**/