mirror of
https://github.com/neovim/neovim.git
synced 2025-10-17 15:21:47 +00:00
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.
368137aa52
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -392,6 +392,10 @@ static void changed_common(buf_T *buf, linenr_T lnum, colnr_T col, linenr_T lnum
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (wp == curwin && xtra != 0 && search_hl_has_cursor_lnum >= lnum) {
|
||||
search_hl_has_cursor_lnum += xtra;
|
||||
}
|
||||
}
|
||||
|
||||
// Call update_screen() later, which checks out what needs to be redrawn,
|
||||
|
@@ -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.
|
||||
|
@@ -25,7 +25,11 @@ EXTERN bool updating_screen INIT( = false);
|
||||
/// must_redraw to be set.
|
||||
EXTERN bool redraw_not_allowed INIT( = false);
|
||||
|
||||
EXTERN match_T screen_search_hl INIT( = { 0 }); ///< used for 'hlsearch' highlight matching
|
||||
/// used for 'hlsearch' highlight matching
|
||||
EXTERN match_T screen_search_hl INIT( = { 0 });
|
||||
|
||||
/// last lnum where CurSearch was displayed
|
||||
EXTERN linenr_T search_hl_has_cursor_lnum INIT( = 0);
|
||||
|
||||
#define W_ENDCOL(wp) ((wp)->w_wincol + (wp)->w_width)
|
||||
#define W_ENDROW(wp) ((wp)->w_winrow + (wp)->w_height)
|
||||
|
@@ -706,6 +706,9 @@ int update_search_hl(win_T *wp, linenr_T lnum, colnr_T col, char **line, match_T
|
||||
// group.
|
||||
if (shl == search_hl && shl->has_cursor) {
|
||||
shl->attr_cur = win_hl_attr(wp, HLF_LC);
|
||||
if (shl->attr_cur != shl->attr) {
|
||||
search_hl_has_cursor_lnum = lnum;
|
||||
}
|
||||
} else {
|
||||
shl->attr_cur = shl->attr;
|
||||
}
|
||||
|
Reference in New Issue
Block a user