vim-patch:8.2.4724: current instance of last search pattern not easily spotted

Problem:    Current instance of last search pattern not easily spotted.
Solution:   Add CurSearch highlighting. (closes vim/vim#10133)

a43993897a

Some code is superseded by later patches that are already ported.

Co-authored-by: LemonBoy <thatlemon@gmail.com>
This commit is contained in:
zeertzjq
2024-06-19 07:32:53 +08:00
parent a2d510e101
commit 14aba67967
6 changed files with 19 additions and 15 deletions

View File

@@ -153,7 +153,6 @@ static void redraw_for_cursorline(win_T *wp)
/// Redraw when w_virtcol changes and
/// - 'cursorcolumn' is set, or
/// - 'cursorlineopt' contains "screenline", or
/// - "CurSearch" highlight is in use, or
/// - 'concealcursor' is active, or
/// - Visual mode is active.
static void redraw_for_cursorcolumn(win_T *wp)
@@ -173,10 +172,8 @@ static void redraw_for_cursorcolumn(win_T *wp)
return;
}
if (wp->w_p_cuc
|| (win_hl_attr(wp, HLF_LC) != win_hl_attr(wp, HLF_L) && using_hlsearch())) {
// When 'cursorcolumn' is set or "CurSearch" is in use
// need to redraw with UPD_SOME_VALID.
if (wp->w_p_cuc) {
// When 'cursorcolumn' is set need to redraw with UPD_SOME_VALID.
redraw_later(wp, UPD_SOME_VALID);
} else if (wp->w_p_cul && (wp->w_p_culopt_flags & CULOPT_SCRLINE)) {
// When 'cursorlineopt' contains "screenline" need to redraw with UPD_VALID.

View File

@@ -3973,6 +3973,12 @@ static void nv_next(cmdarg_T *cap)
normal_search(cap, 0, NULL, 0, SEARCH_MARK | cap->arg, NULL);
cap->count1 -= 1;
}
// Redraw the window to refresh the highlighted matches.
if (i > 0 && p_hls && !no_hlsearch
&& win_hl_attr(curwin, HLF_LC) != win_hl_attr(curwin, HLF_L)) {
redraw_later(curwin, UPD_SOME_VALID);
}
}
/// Search for "pat" in direction "dir" ('/' or '?', 0 for repeat).
@@ -3984,6 +3990,7 @@ static void nv_next(cmdarg_T *cap)
static int normal_search(cmdarg_T *cap, int dir, char *pat, size_t patlen, int opt, int *wrapped)
{
searchit_arg_T sia;
pos_T const prev_cursor = curwin->w_cursor;
cap->oap->motion_type = kMTCharWise;
cap->oap->inclusive = false;
@@ -4007,6 +4014,11 @@ static int normal_search(cmdarg_T *cap, int dir, char *pat, size_t patlen, int o
foldOpenCursor();
}
}
// Redraw the window to refresh the highlighted matches.
if (!equalpos(curwin->w_cursor, prev_cursor) && p_hls && !no_hlsearch
&& win_hl_attr(curwin, HLF_LC) != win_hl_attr(curwin, HLF_L)) {
redraw_later(curwin, UPD_SOME_VALID);
}
// "/$" will put the cursor after the end of the line, may need to
// correct that here

View File

@@ -4322,9 +4322,3 @@ bool search_was_last_used(void)
{
return last_idx == 0;
}
/// @return true if 'hlsearch' highlight is currently in use.
bool using_hlsearch(void)
{
return spats[last_idx].pat != NULL && p_hls && !no_hlsearch;
}