Patch 8.2.3698
Problem: Match highlighting continues over breakindent.
Solution: Stop before the end column. (closes #9242)
Files: src/match.c, src/proto/match.pro, src/drawline.c,
src/testdir/test_match.vim,
src/testdir/dumps/Test_match_linebreak.dump
*** ../vim-8.2.3697/src/match.c 2021-07-27 21:00:39.745712396 +0100
--- src/match.c 2021-11-29 18:59:34.048323596 +0000
***************
*** 703,708 ****
--- 703,710 ----
* 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
***************
*** 715,721 ****
int *has_match_conc UNUSED,
int *match_conc UNUSED,
int did_line_attr,
! int lcs_eol_one)
{
matchitem_T *cur; // points to the match list
match_T *shl; // points to search_hl or a match
--- 717,724 ----
int *has_match_conc UNUSED,
int *match_conc UNUSED,
int did_line_attr,
! int lcs_eol_one,
! int *on_last_col)
{
matchitem_T *cur; // points to the match list
match_T *shl; // points to search_hl or a match
***************
*** 832,838 ****
--- 835,844 ----
else
shl = &cur->hl;
if (shl->attr_cur != 0)
+ {
search_attr = shl->attr_cur;
+ *on_last_col = col + 1 >= shl->endcol;
+ }
if (shl != search_hl && cur != NULL)
cur = cur->next;
}
*** ../vim-8.2.3697/src/proto/match.pro 2020-06-28 12:17:07.551811006 +0100
--- src/proto/match.pro 2021-11-29 19:00:43.832204986 +0000
***************
*** 3,9 ****
void init_search_hl(win_T *wp, match_T *search_hl);
void prepare_search_hl(win_T *wp, match_T *search_hl, linenr_T lnum);
int prepare_search_hl_line(win_T *wp, linenr_T lnum, colnr_T mincol, char_u
**line, match_T *search_hl, int *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 did_line_attr,
int lcs_eol_one);
int get_prevcol_hl_flag(win_T *wp, match_T *search_hl, long curcol);
void get_search_match_hl(win_T *wp, match_T *search_hl, long col, int
*char_attr);
void f_clearmatches(typval_T *argvars, typval_T *rettv);
--- 3,9 ----
void init_search_hl(win_T *wp, match_T *search_hl);
void prepare_search_hl(win_T *wp, match_T *search_hl, linenr_T lnum);
int prepare_search_hl_line(win_T *wp, linenr_T lnum, colnr_T mincol, char_u
**line, match_T *search_hl, int *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 did_line_attr,
int lcs_eol_one, int *on_last_col);
int get_prevcol_hl_flag(win_T *wp, match_T *search_hl, long curcol);
void get_search_match_hl(win_T *wp, match_T *search_hl, long col, int
*char_attr);
void f_clearmatches(typval_T *argvars, typval_T *rettv);
*** ../vim-8.2.3697/src/drawline.c 2021-11-24 16:19:41.389010087 +0000
--- src/drawline.c 2021-11-29 19:10:46.579211196 +0000
***************
*** 434,439 ****
--- 434,440 ----
#if defined(FEAT_CONCEAL) || defined(FEAT_SEARCH_EXTRA)
int match_conc = 0; // cchar for match functions
+ int on_last_col = FALSE;
#endif
#ifdef FEAT_CONCEAL
int syntax_flags = 0;
***************
*** 1382,1388 ****
v = (long)(ptr - line);
search_attr = update_search_hl(wp, lnum, (colnr_T)v, &line,
&screen_search_hl, &has_match_conc,
! &match_conc, did_line_attr, lcs_eol_one);
ptr = line + v; // "line" may have been changed
// Do not allow a conceal over EOL otherwise EOL will be missed
--- 1383,1390 ----
v = (long)(ptr - line);
search_attr = update_search_hl(wp, lnum, (colnr_T)v, &line,
&screen_search_hl, &has_match_conc,
! &match_conc, did_line_attr, lcs_eol_one,
! &on_last_col);
ptr = line + v; // "line" may have been changed
// Do not allow a conceal over EOL otherwise EOL will be missed
***************
*** 2012,2017 ****
--- 2014,2023 ----
if (n_extra < 0)
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 > wp->w_width)
# ifdef FEAT_VARTABS
*** ../vim-8.2.3697/src/testdir/test_match.vim 2020-07-11 21:14:54.314422214
+0100
--- src/testdir/test_match.vim 2021-11-29 19:09:28.803337325 +0000
***************
*** 349,354 ****
--- 349,371 ----
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()
*** ../vim-8.2.3697/src/testdir/dumps/Test_match_linebreak.dump 2021-11-29
19:17:23.302765479 +0000
--- src/testdir/dumps/Test_match_linebreak.dump 2021-11-29 19:09:37.827322662
+0000
***************
*** 0 ****
--- 1,10 ----
+ >x+0&#ffffff0@49|]+0#ffffff16#e000002| +0#0000000#ffffff0@23
+ |x@69| @4
+ |~+0#4040ff13&| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ |~| @73
+ | +0#0000000&@56|1|,|1| @10|A|l@1|
*** ../vim-8.2.3697/src/version.c 2021-11-29 17:37:38.063265208 +0000
--- src/version.c 2021-11-29 19:08:44.399409558 +0000
***************
*** 759,760 ****
--- 759,762 ----
{ /* Add new patch number below this line */
+ /**/
+ 3698,
/**/
--
There are two ways of constructing a software design. One way is to make
it so simple that there are obviously no deficiencies. The other way
is to make it so complicated that there are no obvious deficiencies.
-C.A.R. Hoare
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20211129191923.CBDC21C4F5E%40moolenaar.net.