• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Revisiona680dc1b089d3ea6b743afc93a976c4e7443574b (tree)
Zeit2022-08-12 01:30:04
AutorBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

patch 9.0.0193: search and match highlgith interfere with virtual text

Commit: https://github.com/vim/vim/commit/e38fc86180fd3f6b372648eea6adc3f623fea302
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Aug 11 17:24:50 2022 +0100

patch 9.0.0193: search and match highlgith interfere with virtual text
Problem: Search and match highlgith interfere with virtual text highlight.
(Ben Jackson)
Solution: Check for match highlight after text properties. Reset and
restore search highlight when showing virtual text.
(closes #10892)

Ändern Zusammenfassung

Diff

diff -r a347400a24a9 -r a680dc1b089d src/drawline.c
--- a/src/drawline.c Thu Aug 11 17:00:04 2022 +0200
+++ b/src/drawline.c Thu Aug 11 18:30:04 2022 +0200
@@ -558,6 +558,8 @@
558558 int text_prop_id = 0; // active property ID
559559 int text_prop_flags = 0;
560560 int text_prop_follows = FALSE; // another text prop to display
561+ int saved_search_attr = 0; // search_attr to be used when n_extra
562+ // goes to zero
561563 #endif
562564 #ifdef FEAT_SPELL
563565 int has_spell = FALSE; // this buffer has spell checking
@@ -1583,46 +1585,6 @@
15831585 || (noinvcur && (colnr_T)wlv.vcol == wp->w_virtcol)))
15841586 area_attr = 0; // stop highlighting
15851587
1586-#ifdef FEAT_SEARCH_EXTRA
1587- if (!wlv.n_extra)
1588- {
1589- // Check for start/end of 'hlsearch' and other matches.
1590- // After end, check for start/end of next match.
1591- // When another match, have to check for start again.
1592- v = (long)(ptr - line);
1593- search_attr = update_search_hl(wp, lnum, (colnr_T)v, &line,
1594- &screen_search_hl, &has_match_conc,
1595- &match_conc, did_line_attr, lcs_eol_one,
1596- &on_last_col);
1597- ptr = line + v; // "line" may have been changed
1598- prev_ptr = ptr;
1599-
1600- // Do not allow a conceal over EOL otherwise EOL will be missed
1601- // and bad things happen.
1602- if (*ptr == NUL)
1603- has_match_conc = 0;
1604- }
1605-#endif
1606-
1607-#ifdef FEAT_DIFF
1608- if (wlv.diff_hlf != (hlf_T)0)
1609- {
1610- if (wlv.diff_hlf == HLF_CHD && ptr - line >= change_start
1611- && wlv.n_extra == 0)
1612- wlv.diff_hlf = HLF_TXD; // changed text
1613- if (wlv.diff_hlf == HLF_TXD && ptr - line > change_end
1614- && wlv.n_extra == 0)
1615- wlv.diff_hlf = HLF_CHD; // changed line
1616- line_attr = HL_ATTR(wlv.diff_hlf);
1617- if (wp->w_p_cul && lnum == wp->w_cursor.lnum
1618- && wp->w_p_culopt_flags != CULOPT_NBR
1619- && (!wlv.cul_screenline || (wlv.vcol >= left_curline_col
1620- && wlv.vcol <= right_curline_col)))
1621- line_attr = hl_combine_attr(
1622- line_attr, HL_ATTR(HLF_CUL));
1623- }
1624-#endif
1625-
16261588 #ifdef FEAT_PROP_POPUP
16271589 if (text_props != NULL)
16281590 {
@@ -1748,6 +1710,8 @@
17481710 wlv.n_extra = (int)STRLEN(p);
17491711 extra_attr = used_attr;
17501712 n_attr = mb_charlen(p);
1713+ saved_search_attr = search_attr;
1714+ search_attr = 0; // restore when n_extra is zero
17511715 text_prop_attr = 0;
17521716 if (*ptr == NUL)
17531717 // don't combine char attr after EOL
@@ -1856,6 +1820,46 @@
18561820 }
18571821 #endif
18581822
1823+#ifdef FEAT_SEARCH_EXTRA
1824+ if (wlv.n_extra == 0)
1825+ {
1826+ // Check for start/end of 'hlsearch' and other matches.
1827+ // After end, check for start/end of next match.
1828+ // When another match, have to check for start again.
1829+ v = (long)(ptr - line);
1830+ search_attr = update_search_hl(wp, lnum, (colnr_T)v, &line,
1831+ &screen_search_hl, &has_match_conc,
1832+ &match_conc, did_line_attr, lcs_eol_one,
1833+ &on_last_col);
1834+ ptr = line + v; // "line" may have been changed
1835+ prev_ptr = ptr;
1836+
1837+ // Do not allow a conceal over EOL otherwise EOL will be missed
1838+ // and bad things happen.
1839+ if (*ptr == NUL)
1840+ has_match_conc = 0;
1841+ }
1842+#endif
1843+
1844+#ifdef FEAT_DIFF
1845+ if (wlv.diff_hlf != (hlf_T)0)
1846+ {
1847+ if (wlv.diff_hlf == HLF_CHD && ptr - line >= change_start
1848+ && wlv.n_extra == 0)
1849+ wlv.diff_hlf = HLF_TXD; // changed text
1850+ if (wlv.diff_hlf == HLF_TXD && ptr - line > change_end
1851+ && wlv.n_extra == 0)
1852+ wlv.diff_hlf = HLF_CHD; // changed line
1853+ line_attr = HL_ATTR(wlv.diff_hlf);
1854+ if (wp->w_p_cul && lnum == wp->w_cursor.lnum
1855+ && wp->w_p_culopt_flags != CULOPT_NBR
1856+ && (!wlv.cul_screenline || (wlv.vcol >= left_curline_col
1857+ && wlv.vcol <= right_curline_col)))
1858+ line_attr = hl_combine_attr(
1859+ line_attr, HL_ATTR(HLF_CUL));
1860+ }
1861+#endif
1862+
18591863 #ifdef FEAT_SYN_HL
18601864 if (extra_check && wlv.n_extra == 0)
18611865 {
@@ -2086,9 +2090,13 @@
20862090 ++wlv.p_extra;
20872091 }
20882092 --wlv.n_extra;
2089-#if defined(FEAT_LINEBREAK) && defined(FEAT_PROP_POPUP)
2093+#if defined(FEAT_PROP_POPUP)
20902094 if (wlv.n_extra <= 0)
2095+ {
20912096 in_linebreak = FALSE;
2097+ if (search_attr == 0)
2098+ search_attr = saved_search_attr;
2099+ }
20922100 #endif
20932101 }
20942102 else
diff -r a347400a24a9 -r a680dc1b089d src/testdir/dumps/Test_prop_inserts_text_hi_1.dump
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/dumps/Test_prop_inserts_text_hi_1.dump Thu Aug 11 18:30:04 2022 +0200
@@ -0,0 +1,6 @@
1+>i+0&#ffffff0|n|s|e|r|t| |s|o|m|e| |t|e|x|t| |B+0#ffffff16#e000002|E|F|O|R|E|(+0#0000000#5fd7ff255|h+0&#ffffff0|e|r|e|)| |a|n|d| |t|h|e|r|e| @20
2+|~+0#4040ff13&| @58
3+|~| @58
4+|~| @58
5+|~| @58
6+| +0#0000000&@41|1|,|1| @10|A|l@1|
diff -r a347400a24a9 -r a680dc1b089d src/testdir/dumps/Test_prop_inserts_text_hi_2.dump
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/dumps/Test_prop_inserts_text_hi_2.dump Thu Aug 11 18:30:04 2022 +0200
@@ -0,0 +1,6 @@
1+|i+0&#ffffff0|n|s|e|r|t| |s|o|m|e| >t+0&#ffff4012|e|x|t| |B+0#ffffff16#e000002|E|F|O|R|E|(+0#0000000#5fd7ff255|h+0&#ffff4012|e|r+0&#ffffff0|e|)| |a|n|d| |t|h|e|r|e| @20
2+|~+0#4040ff13&| @58
3+|~| @58
4+|~| @58
5+|~| @58
6+|/+0#0000000&|t|e|x|t| |(|h|e| @32|1|,|1|3| @9|A|l@1|
diff -r a347400a24a9 -r a680dc1b089d src/testdir/dumps/Test_prop_inserts_text_hi_3.dump
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/dumps/Test_prop_inserts_text_hi_3.dump Thu Aug 11 18:30:04 2022 +0200
@@ -0,0 +1,6 @@
1+|i+0&#ffffff0|n|s|e|r|t| |s|o|m|e| >t+0&#ffff4012|e|x|t| |B+0#ffffff16#e000002|E|F|O|R|E|(+0#0000000#ffff4012|h|e|r+0&#ffffff0|e|)| |a|n|d| |t|h|e|r|e| @20
2+|~+0#4040ff13&| @58
3+|~| @58
4+|~| @58
5+|~| @58
6+|:+0#0000000&|c|a|l@1| |m|a|t|c|h|d|e|l|e|t|e|(|t|h|e|m|a|t|c|h|)| @14|1|,|1|3| @9|A|l@1|
diff -r a347400a24a9 -r a680dc1b089d src/testdir/dumps/Test_prop_inserts_text_hi_4.dump
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/dumps/Test_prop_inserts_text_hi_4.dump Thu Aug 11 18:30:04 2022 +0200
@@ -0,0 +1,6 @@
1+|i+0&#ffffff0|n|s|e|r|t| |s|o|m|e| >t|e|x|t| |(+0&#5fd7ff255|A+0#ffffff16#e000002|F|T|E|R|h+0#0000000#ffffff0|e|r|e|)| |a|n|d| |t|h|e|r|e| @21
2+|~+0#4040ff13&| @58
3+|~| @58
4+|~| @58
5+|~| @58
6+|:+0#0000000&|c|a|l@1| |D|o|A|f|t|e|r|(|)| @26|1|,|1|3| @9|A|l@1|
diff -r a347400a24a9 -r a680dc1b089d src/testdir/dumps/Test_prop_inserts_text_hi_5.dump
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/dumps/Test_prop_inserts_text_hi_5.dump Thu Aug 11 18:30:04 2022 +0200
@@ -0,0 +1,6 @@
1+|i+0&#ffffff0|n|s|e|r|t| |s|o|m|e| >t+0&#ffff4012|e|x|t| |(+0&#5fd7ff255|A+0#ffffff16#e000002|F|T|E|R|h+0#0000000#ffff4012|e|r+0&#ffffff0|e|)| |a|n|d| |t|h|e|r|e| @21
2+|~+0#4040ff13&| @58
3+|~| @58
4+|~| @58
5+|~| @58
6+|s+0#e000002&|e|a|r|c|h| |h|i|t| |B|O|T|.@2|t|i|n|u|i|n|g| |a|t| |T|O|P| +0#0000000&@10|1|,|1|3| @9|A|l@1|
diff -r a347400a24a9 -r a680dc1b089d src/testdir/dumps/Test_prop_inserts_text_hi_6.dump
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/testdir/dumps/Test_prop_inserts_text_hi_6.dump Thu Aug 11 18:30:04 2022 +0200
@@ -0,0 +1,6 @@
1+|i+0&#ffffff0|n|s|e|r|t| |s|o|m|e| >t+0&#ffff4012|e|x|t| |(|A+0#ffffff16#e000002|F|T|E|R|h+0#0000000#ffff4012|e|r+0&#ffffff0|e|)| |a|n|d| |t|h|e|r|e| @21
2+|~+0#4040ff13&| @58
3+|~| @58
4+|~| @58
5+|~| @58
6+|:+0#0000000&|c|a|l@1| |m|a|t|c|h|d|e|l|e|t|e|(|t|h|e|m|a|t|c|h|)| @14|1|,|1|3| @9|A|l@1|
diff -r a347400a24a9 -r a680dc1b089d src/testdir/test_textprop.vim
--- a/src/testdir/test_textprop.vim Thu Aug 11 17:00:04 2022 +0200
+++ b/src/testdir/test_textprop.vim Thu Aug 11 18:30:04 2022 +0200
@@ -2502,6 +2502,42 @@
25022502 call delete('XscriptPropsWithText')
25032503 endfunc
25042504
2505+func Test_prop_inserts_text_highlight()
2506+ CheckRunVimInTerminal
2507+
2508+ " Just a basic check for now
2509+ let lines =<< trim END
2510+ call setline(1, 'insert some text (here) and there')
2511+ call prop_type_add('someprop', #{highlight: 'ErrorMsg'})
2512+ let bef_prop = prop_add(1, 18, #{type: 'someprop', text: 'BEFORE'})
2513+ set hlsearch
2514+ let thematch = matchaddpos("DiffAdd", [[1, 18]])
2515+ func DoAfter()
2516+ call prop_remove(#{id: g:bef_prop})
2517+ call prop_add(1, 19, #{type: 'someprop', text: 'AFTER'})
2518+ let g:thematch = matchaddpos("DiffAdd", [[1, 18]])
2519+ let @/ = ''
2520+ endfunc
2521+ END
2522+ call writefile(lines, 'XscriptPropsWithHighlight')
2523+ let buf = RunVimInTerminal('-S XscriptPropsWithHighlight', #{rows: 6, cols: 60})
2524+ call VerifyScreenDump(buf, 'Test_prop_inserts_text_hi_1', {})
2525+ call term_sendkeys(buf, "/text (he\<CR>")
2526+ call VerifyScreenDump(buf, 'Test_prop_inserts_text_hi_2', {})
2527+ call term_sendkeys(buf, ":call matchdelete(thematch)\<CR>")
2528+ call VerifyScreenDump(buf, 'Test_prop_inserts_text_hi_3', {})
2529+
2530+ call term_sendkeys(buf, ":call DoAfter()\<CR>")
2531+ call VerifyScreenDump(buf, 'Test_prop_inserts_text_hi_4', {})
2532+ call term_sendkeys(buf, "/text (he\<CR>")
2533+ call VerifyScreenDump(buf, 'Test_prop_inserts_text_hi_5', {})
2534+ call term_sendkeys(buf, ":call matchdelete(thematch)\<CR>")
2535+ call VerifyScreenDump(buf, 'Test_prop_inserts_text_hi_6', {})
2536+
2537+ call StopVimInTerminal(buf)
2538+ call delete('XscriptPropsWithHighlight')
2539+endfunc
2540+
25052541 func Test_props_with_text_after()
25062542 CheckRunVimInTerminal
25072543
diff -r a347400a24a9 -r a680dc1b089d src/version.c
--- a/src/version.c Thu Aug 11 17:00:04 2022 +0200
+++ b/src/version.c Thu Aug 11 18:30:04 2022 +0200
@@ -736,6 +736,8 @@
736736 static int included_patches[] =
737737 { /* Add new patch number below this line */
738738 /**/
739+ 193,
740+/**/
739741 192,
740742 /**/
741743 191,
Show on old repository browser