mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.4805: CurSearch used for all matches in current line
Problem: CurSearch used for all matches in current line. Solution: Don't use the non-zero line count. (closes #10247)
This commit is contained in:
parent
1fc6ea9bf3
commit
9b36750640
39
src/match.c
39
src/match.c
@ -617,6 +617,26 @@ prepare_search_hl(win_T *wp, match_T *search_hl, linenr_T lnum)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Update "shl->has_cursor" based on the match in "shl" and the cursor
|
||||||
|
* position.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
check_cur_search_hl(win_T *wp, match_T *shl)
|
||||||
|
{
|
||||||
|
long linecount = shl->rm.endpos[0].lnum - shl->rm.startpos[0].lnum;
|
||||||
|
|
||||||
|
if (wp->w_cursor.lnum >= shl->lnum
|
||||||
|
&& wp->w_cursor.lnum <= shl->lnum + shl->rm.endpos[0].lnum
|
||||||
|
&& (wp->w_cursor.lnum > shl->lnum
|
||||||
|
|| wp->w_cursor.col >= shl->rm.startpos[0].col)
|
||||||
|
&& (wp->w_cursor.lnum < shl->lnum + linecount
|
||||||
|
|| wp->w_cursor.col < shl->rm.endpos[0].col))
|
||||||
|
shl->has_cursor = TRUE;
|
||||||
|
else
|
||||||
|
shl->has_cursor = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prepare for 'hlsearch' and match highlighting in one window line.
|
* Prepare for 'hlsearch' and match highlighting in one window line.
|
||||||
* Return TRUE if there is such highlighting and set "search_attr" to the
|
* Return TRUE if there is such highlighting and set "search_attr" to the
|
||||||
@ -677,20 +697,13 @@ prepare_search_hl_line(
|
|||||||
shl->endcol = shl->rm.endpos[0].col;
|
shl->endcol = shl->rm.endpos[0].col;
|
||||||
else
|
else
|
||||||
shl->endcol = MAXCOL;
|
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;
|
||||||
shl->lines = shl->rm.endpos[0].lnum - shl->rm.startpos[0].lnum;
|
if (shl->lines == 0)
|
||||||
else
|
|
||||||
shl->lines = 1;
|
shl->lines = 1;
|
||||||
|
|
||||||
// check if the cursor is in the match before changing the columns
|
// check if the cursor is in the match before changing the columns
|
||||||
if (wp->w_cursor.lnum >= shl->lnum
|
if (shl == search_hl)
|
||||||
&& wp->w_cursor.lnum
|
check_cur_search_hl(wp, shl);
|
||||||
<= shl->lnum + shl->rm.endpos[0].lnum
|
|
||||||
&& (wp->w_cursor.lnum > shl->lnum
|
|
||||||
|| wp->w_cursor.col >= shl->rm.startpos[0].col)
|
|
||||||
&& (wp->w_cursor.lnum < shl->lnum + shl->lines
|
|
||||||
|| wp->w_cursor.col < shl->rm.endpos[0].col))
|
|
||||||
shl->has_cursor = TRUE;
|
|
||||||
|
|
||||||
// Highlight one character for an empty match.
|
// Highlight one character for an empty match.
|
||||||
if (shl->startcol == shl->endcol)
|
if (shl->startcol == shl->endcol)
|
||||||
@ -811,6 +824,10 @@ update_search_hl(
|
|||||||
else
|
else
|
||||||
shl->endcol = MAXCOL;
|
shl->endcol = MAXCOL;
|
||||||
|
|
||||||
|
// check if the cursor is in the match
|
||||||
|
if (shl == search_hl)
|
||||||
|
check_cur_search_hl(wp, shl);
|
||||||
|
|
||||||
if (shl->startcol == shl->endcol)
|
if (shl->startcol == shl->endcol)
|
||||||
{
|
{
|
||||||
// highlight empty match, try again after
|
// highlight empty match, try again after
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
>f+0࿈ff13|o@1| +0&#ffffff0@56
|
>f+0࿈ff13|o@1| +0&#ffffff0@56
|
||||||
|b|a|r| @56
|
|b|a|r| @56
|
||||||
|b|a|z| @56
|
|b|a|z| @56
|
||||||
|f+0&#ffff4012|o@1| +0&#ffffff0@56
|
|f+0&#ffff4012|o@1| +0&#ffffff0|t|h|e| |f+0&#ffff4012|o@1| +0&#ffffff0|a|n|d| |f+0&#ffff4012|o@1| +0&#ffffff0@40
|
||||||
|b|a|r| @56
|
|b|a|r| @56
|
||||||
|~+0#4040ff13&| @58
|
|~+0#4040ff13&| @58
|
||||||
|~| @58
|
|~| @58
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|f+0&#ffff4012|o@1| +0&#ffffff0@56
|
|f+0&#ffff4012|o@1| +0&#ffffff0@56
|
||||||
|b|a|r| @56
|
|b|a|r| @56
|
||||||
|b|a|z| @56
|
|b|a|z| @56
|
||||||
>f+0࿈ff13|o@1| +0&#ffffff0@56
|
>f+0࿈ff13|o@1| +0&#ffffff0|t|h|e| |f+0&#ffff4012|o@1| +0&#ffffff0|a|n|d| |f+0&#ffff4012|o@1| +0&#ffffff0@40
|
||||||
|b|a|r| @56
|
|b|a|r| @56
|
||||||
|~+0#4040ff13&| @58
|
|~+0#4040ff13&| @58
|
||||||
|~| @58
|
|~| @58
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
|o+0&#ffffff0|n|e| @56
|
||||||
|
|f+0&#ffff4012|o@1| +0&#ffffff0@56
|
||||||
|
|b|a|r| @56
|
||||||
|
|b|a|z| @56
|
||||||
|
|f+0&#ffff4012|o@1| +0&#ffffff0|t|h|e| >f+0࿈ff13|o@1| +0&#ffffff0|a|n|d| |f+0&#ffff4012|o@1| +0&#ffffff0@40
|
||||||
|
|b|a|r| @56
|
||||||
|
|~+0#4040ff13&| @58
|
||||||
|
|~| @58
|
||||||
|
|/+0#0000000&|f|o@1| @37|5|,|9| @10|A|l@1|
|
@ -0,0 +1,9 @@
|
|||||||
|
|o+0&#ffffff0|n|e| @56
|
||||||
|
|f+0&#ffff4012|o@1| +0&#ffffff0@56
|
||||||
|
|b|a|r| @56
|
||||||
|
|b|a|z| @56
|
||||||
|
|f+0&#ffff4012|o@1| +0&#ffffff0|t|h|e| |f+0&#ffff4012|o@1| +0&#ffffff0|a|n|d| >f+0࿈ff13|o@1| +0&#ffffff0@40
|
||||||
|
|b|a|r| @56
|
||||||
|
|~+0#4040ff13&| @58
|
||||||
|
|~| @58
|
||||||
|
|/+0#0000000&|f|o@1| @37|5|,|1|7| @9|A|l@1|
|
@ -1043,7 +1043,7 @@ func Test_hlsearch_cursearch()
|
|||||||
|
|
||||||
let lines =<< trim END
|
let lines =<< trim END
|
||||||
set hlsearch scrolloff=0
|
set hlsearch scrolloff=0
|
||||||
call setline(1, ['one', 'foo', 'bar', 'baz', 'foo', 'bar'])
|
call setline(1, ['one', 'foo', 'bar', 'baz', 'foo the foo and foo', 'bar'])
|
||||||
hi Search ctermbg=yellow
|
hi Search ctermbg=yellow
|
||||||
hi CurSearch ctermbg=blue
|
hi CurSearch ctermbg=blue
|
||||||
END
|
END
|
||||||
@ -1056,7 +1056,14 @@ func Test_hlsearch_cursearch()
|
|||||||
call term_sendkeys(buf, "n")
|
call term_sendkeys(buf, "n")
|
||||||
call VerifyScreenDump(buf, 'Test_hlsearch_cursearch_single_line_2', {})
|
call VerifyScreenDump(buf, 'Test_hlsearch_cursearch_single_line_2', {})
|
||||||
|
|
||||||
call term_sendkeys(buf, "?\<CR>")
|
call term_sendkeys(buf, "n")
|
||||||
|
call VerifyScreenDump(buf, 'Test_hlsearch_cursearch_single_line_2a', {})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, "n")
|
||||||
|
call VerifyScreenDump(buf, 'Test_hlsearch_cursearch_single_line_2b', {})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, ":call setline(5, 'foo')\<CR>")
|
||||||
|
call term_sendkeys(buf, "0?\<CR>")
|
||||||
call VerifyScreenDump(buf, 'Test_hlsearch_cursearch_single_line_3', {})
|
call VerifyScreenDump(buf, 'Test_hlsearch_cursearch_single_line_3', {})
|
||||||
|
|
||||||
call term_sendkeys(buf, "gg/foo\\nbar\<CR>")
|
call term_sendkeys(buf, "gg/foo\\nbar\<CR>")
|
||||||
|
@ -746,6 +746,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4805,
|
||||||
/**/
|
/**/
|
||||||
4804,
|
4804,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user