aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/match.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-04-20 20:42:55 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-04-21 06:24:11 +0800
commit81453579745516316067ba8154eb02e1305114fc (patch)
treee724eda0cf298123b3410d3d96350d845a35d159 /src/nvim/match.c
parentbfd6eb4404d7250d1b59fc24f08a9392fba0c043 (diff)
downloadrneovim-81453579745516316067ba8154eb02e1305114fc.tar.gz
rneovim-81453579745516316067ba8154eb02e1305114fc.tar.bz2
rneovim-81453579745516316067ba8154eb02e1305114fc.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 This fixes CurSearch highlight for multiline match. Omit screen redrawing code because Nvim redraws CurSearch differently.
Diffstat (limited to 'src/nvim/match.c')
-rw-r--r--src/nvim/match.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/nvim/match.c b/src/nvim/match.c
index 4129e84fc2..256e5812d4 100644
--- a/src/nvim/match.c
+++ b/src/nvim/match.c
@@ -582,6 +582,7 @@ bool prepare_search_hl_line(win_T *wp, linenr_T lnum, colnr_T mincol, char_u **l
}
shl->startcol = MAXCOL;
shl->endcol = MAXCOL;
+ shl->lines = 0;
shl->attr_cur = 0;
shl->is_addpos = false;
if (cur != NULL) {
@@ -606,6 +607,11 @@ bool prepare_search_hl_line(win_T *wp, linenr_T lnum, colnr_T mincol, char_u **l
} else {
shl->endcol = MAXCOL;
}
+ if (shl->rm.endpos[0].lnum != shl->rm.startpos[0].lnum) {
+ shl->lines = shl->rm.endpos[0].lnum - shl->rm.startpos[0].lnum;
+ } else {
+ shl->lines = 1;
+ }
// Highlight one character for an empty match.
if (shl->startcol == shl->endcol) {
if ((*line)[shl->endcol] != NUL) {
@@ -668,10 +674,12 @@ int update_search_hl(win_T *wp, linenr_T lnum, colnr_T col, char_u **line, match
if (shl->endcol < next_col) {
shl->endcol = next_col;
}
- // Use "CurSearch" highlight for current search match
+ // Highlight the match were the cursor is using the CurSearch
+ // group.
if (shl == search_hl
&& (HL_ATTR(HLF_LC) || wp->w_hl_ids[HLF_LC])
&& wp->w_cursor.lnum == lnum
+ && wp->w_cursor.lnum < shl->lnum + shl->lines
&& wp->w_cursor.col >= shl->startcol
&& wp->w_cursor.col < shl->endcol) {
shl->attr_cur = win_hl_attr(wp, HLF_LC) ? win_hl_attr(wp, HLF_LC) : HL_ATTR(HLF_LC);