mirror of
https://github.com/neovim/neovim.git
synced 2025-10-14 22:06:07 +00:00
vim-patch:8.2.3698: match highlighting continues over breakindent
Problem: Match highlighting continues over breakindent.
Solution: Stop before the end column. (closes vim/vim#9242)
0c359af5c0
Cherry-pick Test_matchdelete_redraw() from patch 8.2.1077.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
@@ -618,6 +618,8 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
|
||||
LineDrawState draw_state = WL_START; // what to draw next
|
||||
|
||||
int match_conc = 0; ///< cchar for match functions
|
||||
bool on_last_col = false;
|
||||
int syntax_flags = 0;
|
||||
int syntax_seqnr = 0;
|
||||
int prev_syntax_id = 0;
|
||||
@@ -627,7 +629,6 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
///< force wrapping
|
||||
int vcol_off = 0; ///< offset for concealed characters
|
||||
int did_wcol = false;
|
||||
int match_conc = 0; ///< cchar for match functions
|
||||
int old_boguscols = 0;
|
||||
#define VCOL_HLC (vcol - vcol_off)
|
||||
#define FIX_FOR_BOGUSCOLS \
|
||||
@@ -1429,8 +1430,8 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
// When another match, have to check for start again.
|
||||
v = (ptr - line);
|
||||
search_attr = update_search_hl(wp, lnum, (colnr_T)v, &line, &screen_search_hl,
|
||||
&has_match_conc,
|
||||
&match_conc, lcs_eol_one, &search_attr_from_match);
|
||||
&has_match_conc, &match_conc, lcs_eol_one,
|
||||
&on_last_col, &search_attr_from_match);
|
||||
ptr = line + v; // "line" may have been changed
|
||||
|
||||
// Do not allow a conceal over EOL otherwise EOL will be missed
|
||||
@@ -1843,6 +1844,11 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool nochange,
|
||||
n_extra = 0;
|
||||
}
|
||||
}
|
||||
if (on_last_col) {
|
||||
// Do not continue search/match highlighting over the
|
||||
// line break.
|
||||
search_attr = 0;
|
||||
}
|
||||
|
||||
if (c == TAB && n_extra + col > grid->cols) {
|
||||
n_extra = tabstop_padding((colnr_T)vcol, wp->w_buffer->b_p_ts,
|
||||
|
@@ -677,9 +677,11 @@ bool prepare_search_hl_line(win_T *wp, linenr_T lnum, colnr_T mincol, char_u **l
|
||||
/// After end, check for start/end of next match.
|
||||
/// When another match, have to check for start again.
|
||||
/// Watch out for matching an empty string!
|
||||
/// "on_last_col" is set to true with non-zero search_attr and the next column
|
||||
/// is endcol.
|
||||
/// Return the updated search_attr.
|
||||
int update_search_hl(win_T *wp, linenr_T lnum, colnr_T col, char_u **line, match_T *search_hl,
|
||||
int *has_match_conc, int *match_conc, int lcs_eol_one,
|
||||
int *has_match_conc, int *match_conc, int lcs_eol_one, bool *on_last_col,
|
||||
bool *search_attr_from_match)
|
||||
{
|
||||
matchitem_T *cur = wp->w_match_head; // points to the match list
|
||||
@@ -792,6 +794,7 @@ int update_search_hl(win_T *wp, linenr_T lnum, colnr_T col, char_u **line, match
|
||||
}
|
||||
if (shl->attr_cur != 0) {
|
||||
search_attr = shl->attr_cur;
|
||||
*on_last_col = col + 1 >= shl->endcol;
|
||||
*search_attr_from_match = shl != search_hl;
|
||||
}
|
||||
if (shl != search_hl && cur != NULL) {
|
||||
|
@@ -363,4 +363,41 @@ func Test_matchadd_other_window()
|
||||
call delete('XscriptMatchCommon')
|
||||
endfunc
|
||||
|
||||
func Test_match_in_linebreak()
|
||||
CheckRunVimInTerminal
|
||||
|
||||
let lines =<< trim END
|
||||
set breakindent linebreak breakat+=]
|
||||
call printf('%s]%s', repeat('x', 50), repeat('x', 70))->setline(1)
|
||||
call matchaddpos('ErrorMsg', [[1, 51]])
|
||||
END
|
||||
call writefile(lines, 'XscriptMatchLinebreak')
|
||||
let buf = RunVimInTerminal('-S XscriptMatchLinebreak', #{rows: 10})
|
||||
call TermWait(buf)
|
||||
call VerifyScreenDump(buf, 'Test_match_linebreak', {})
|
||||
|
||||
call StopVimInTerminal(buf)
|
||||
call delete('XscriptMatchLinebreak')
|
||||
endfunc
|
||||
|
||||
" Test for deleting matches outside of the screen redraw top/bottom lines
|
||||
" This should cause a redraw of those lines.
|
||||
func Test_matchdelete_redraw()
|
||||
new
|
||||
call setline(1, range(1, 500))
|
||||
call cursor(250, 1)
|
||||
let m1 = matchaddpos('Search', [[250]])
|
||||
let m2 = matchaddpos('Search', [[10], [450]])
|
||||
redraw!
|
||||
let m3 = matchaddpos('Search', [[240], [260]])
|
||||
call matchdelete(m2)
|
||||
let m = getmatches()
|
||||
call assert_equal(2, len(m))
|
||||
call assert_equal([250], m[0].pos1)
|
||||
redraw!
|
||||
call matchdelete(m1)
|
||||
call assert_equal(1, len(getmatches()))
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Reference in New Issue
Block a user