aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/normal.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-06-19 07:32:53 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-06-19 08:02:02 +0800
commit14aba679670a6485596c60fa5eb1df92ecae8a1b (patch)
tree5ab2fbbf939d38ee2d6b75e1ff0263d60f129e5d /src/nvim/normal.c
parenta2d510e1015d57f28ab20c5d2897527cae15b9c4 (diff)
downloadrneovim-14aba679670a6485596c60fa5eb1df92ecae8a1b.tar.gz
rneovim-14aba679670a6485596c60fa5eb1df92ecae8a1b.tar.bz2
rneovim-14aba679670a6485596c60fa5eb1df92ecae8a1b.zip
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) https://github.com/vim/vim/commit/a43993897aa372159f682df37562f159994dc85c Some code is superseded by later patches that are already ported. Co-authored-by: LemonBoy <thatlemon@gmail.com>
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r--src/nvim/normal.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 3343803bb1..cbd068401a 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -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