aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/drawscreen.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-06-19 07:42:56 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-06-19 08:02:29 +0800
commita2a3e8412e6d4e9a952c57a5298016cae8bf5229 (patch)
tree4c606a997f28a74b531ab2888e2f59eac5329d70 /src/nvim/drawscreen.c
parent14aba679670a6485596c60fa5eb1df92ecae8a1b (diff)
downloadrneovim-a2a3e8412e6d4e9a952c57a5298016cae8bf5229.tar.gz
rneovim-a2a3e8412e6d4e9a952c57a5298016cae8bf5229.tar.bz2
rneovim-a2a3e8412e6d4e9a952c57a5298016cae8bf5229.zip
vim-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. https://github.com/vim/vim/commit/368137aa525982984beed73940af481ac53a62af Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/drawscreen.c')
-rw-r--r--src/nvim/drawscreen.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c
index 88e1f302da..770f8da6cf 100644
--- a/src/nvim/drawscreen.c
+++ b/src/nvim/drawscreen.c
@@ -1593,6 +1593,18 @@ static void win_update(win_T *wp)
}
}
}
+
+ 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;
+ }
+ }
+
if (mod_top != 0 && hasAnyFolding(wp)) {
// A change in a line can cause lines above it to become folded or
// unfolded. Find the top most buffer line that may be affected.
@@ -1651,6 +1663,7 @@ static void win_update(win_T *wp)
wp->w_redraw_top = 0; // reset for next time
wp->w_redraw_bot = 0;
+ search_hl_has_cursor_lnum = 0;
// When only displaying the lines at the top, set top_end. Used when
// window has scrolled down for msg_scrolled.