forked from aniani/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.
This commit is contained in:
@@ -663,6 +663,10 @@ changed_common(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef FEAT_SEARCH_EXTRA
|
||||||
|
if (wp == curwin && xtra != 0 && search_hl_has_cursor_lnum >= lnum)
|
||||||
|
search_hl_has_cursor_lnum += xtra;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call update_screen() later, which checks out what needs to be redrawn,
|
// Call update_screen() later, which checks out what needs to be redrawn,
|
||||||
|
|||||||
@@ -1618,6 +1618,19 @@ win_update(win_T *wp)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef FEAT_SEARCH_EXTRA
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
if (mod_top != 0 && hasAnyFolding(wp))
|
if (mod_top != 0 && hasAnyFolding(wp))
|
||||||
{
|
{
|
||||||
@@ -1684,6 +1697,10 @@ win_update(win_T *wp)
|
|||||||
}
|
}
|
||||||
wp->w_redraw_top = 0; // reset for next time
|
wp->w_redraw_top = 0; // reset for next time
|
||||||
wp->w_redraw_bot = 0;
|
wp->w_redraw_bot = 0;
|
||||||
|
#ifdef FEAT_SEARCH_EXTRA
|
||||||
|
search_hl_has_cursor_lnum = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// When only displaying the lines at the top, set top_end. Used when
|
// When only displaying the lines at the top, set top_end. Used when
|
||||||
// window has scrolled down for msg_scrolled.
|
// window has scrolled down for msg_scrolled.
|
||||||
|
|||||||
@@ -75,7 +75,14 @@ EXTERN int screen_cur_row INIT(= 0);
|
|||||||
EXTERN int screen_cur_col INIT(= 0);
|
EXTERN int screen_cur_col INIT(= 0);
|
||||||
|
|
||||||
#ifdef FEAT_SEARCH_EXTRA
|
#ifdef FEAT_SEARCH_EXTRA
|
||||||
EXTERN match_T screen_search_hl; // used for 'hlsearch' highlight matching
|
// used for 'hlsearch' highlight matching
|
||||||
|
EXTERN match_T screen_search_hl;
|
||||||
|
|
||||||
|
// last lnum where CurSearch was displayed
|
||||||
|
EXTERN linenr_T search_hl_has_cursor_lnum INIT(= 0);
|
||||||
|
|
||||||
|
// don't use 'hlsearch' temporarily
|
||||||
|
EXTERN int no_hlsearch INIT(= FALSE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
@@ -1418,11 +1425,6 @@ EXTERN char_u wim_flags[4];
|
|||||||
EXTERN int stl_syntax INIT(= 0);
|
EXTERN int stl_syntax INIT(= 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FEAT_SEARCH_EXTRA
|
|
||||||
// don't use 'hlsearch' temporarily
|
|
||||||
EXTERN int no_hlsearch INIT(= FALSE);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(FEAT_BEVAL) && !defined(NO_X11_INCLUDES)
|
#if defined(FEAT_BEVAL) && !defined(NO_X11_INCLUDES)
|
||||||
EXTERN BalloonEval *balloonEval INIT(= NULL);
|
EXTERN BalloonEval *balloonEval INIT(= NULL);
|
||||||
EXTERN int balloonEvalForTerm INIT(= FALSE);
|
EXTERN int balloonEvalForTerm INIT(= FALSE);
|
||||||
|
|||||||
@@ -798,7 +798,11 @@ update_search_hl(
|
|||||||
// Highlight the match were the cursor is using the CurSearch
|
// Highlight the match were the cursor is using the CurSearch
|
||||||
// group.
|
// group.
|
||||||
if (shl == search_hl && shl->has_cursor)
|
if (shl == search_hl && shl->has_cursor)
|
||||||
|
{
|
||||||
shl->attr_cur = HL_ATTR(HLF_LC);
|
shl->attr_cur = HL_ATTR(HLF_LC);
|
||||||
|
if (shl->attr_cur != shl->attr)
|
||||||
|
search_hl_has_cursor_lnum = lnum;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (col == shl->endcol)
|
else if (col == shl->endcol)
|
||||||
|
|||||||
9
src/testdir/dumps/Test_hlsearch_cursearch_changed_1.dump
Normal file
9
src/testdir/dumps/Test_hlsearch_cursearch_changed_1.dump
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
|-+0&#ffffff0@2| @56
|
||||||
|
|a+0&#ffff4012|b|c|d|e+0&#ffffff0|f|g| @52
|
||||||
|
>a+0࿈ff13|b|c|d|e+0&#ffffff0|f|g| @52
|
||||||
|
|h|i|j|k|l| @54
|
||||||
|
|-@2| @56
|
||||||
|
|a+0&#ffff4012|b|c|d|e+0&#ffffff0|f|g| @52
|
||||||
|
|h|i|j|k|l| @54
|
||||||
|
|~+0#4040ff13&| @58
|
||||||
|
| +0#0000000&@41|3|,|1| @10|A|l@1|
|
||||||
@@ -1079,6 +1079,11 @@ func Test_hlsearch_cursearch()
|
|||||||
call term_sendkeys(buf, "h\<C-L>")
|
call term_sendkeys(buf, "h\<C-L>")
|
||||||
call VerifyScreenDump(buf, 'Test_hlsearch_cursearch_multiple_line_5', {})
|
call VerifyScreenDump(buf, 'Test_hlsearch_cursearch_multiple_line_5', {})
|
||||||
|
|
||||||
|
" check clearing CurSearch when using it for another match
|
||||||
|
call term_sendkeys(buf, "G?^abcd\<CR>Y")
|
||||||
|
call term_sendkeys(buf, "kkP")
|
||||||
|
call VerifyScreenDump(buf, 'Test_hlsearch_cursearch_changed_1', {})
|
||||||
|
|
||||||
call StopVimInTerminal(buf)
|
call StopVimInTerminal(buf)
|
||||||
call delete('Xhlsearch_cursearch')
|
call delete('Xhlsearch_cursearch')
|
||||||
endfunc
|
endfunc
|
||||||
|
|||||||
@@ -734,6 +734,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 */
|
||||||
|
/**/
|
||||||
|
5047,
|
||||||
/**/
|
/**/
|
||||||
5046,
|
5046,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Reference in New Issue
Block a user