Mirror of the Vim source from https://github.com/vim/vim
Revision | a680dc1b089d3ea6b743afc93a976c4e7443574b (tree) |
---|---|
Zeit | 2022-08-12 01:30:04 |
Autor | Bram Moolenaar <Bram@vim....> |
Commiter | Bram Moolenaar |
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
@@ -558,6 +558,8 @@ | ||
558 | 558 | int text_prop_id = 0; // active property ID |
559 | 559 | int text_prop_flags = 0; |
560 | 560 | 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 | |
561 | 563 | #endif |
562 | 564 | #ifdef FEAT_SPELL |
563 | 565 | int has_spell = FALSE; // this buffer has spell checking |
@@ -1583,46 +1585,6 @@ | ||
1583 | 1585 | || (noinvcur && (colnr_T)wlv.vcol == wp->w_virtcol))) |
1584 | 1586 | area_attr = 0; // stop highlighting |
1585 | 1587 | |
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 | - | |
1626 | 1588 | #ifdef FEAT_PROP_POPUP |
1627 | 1589 | if (text_props != NULL) |
1628 | 1590 | { |
@@ -1748,6 +1710,8 @@ | ||
1748 | 1710 | wlv.n_extra = (int)STRLEN(p); |
1749 | 1711 | extra_attr = used_attr; |
1750 | 1712 | n_attr = mb_charlen(p); |
1713 | + saved_search_attr = search_attr; | |
1714 | + search_attr = 0; // restore when n_extra is zero | |
1751 | 1715 | text_prop_attr = 0; |
1752 | 1716 | if (*ptr == NUL) |
1753 | 1717 | // don't combine char attr after EOL |
@@ -1856,6 +1820,46 @@ | ||
1856 | 1820 | } |
1857 | 1821 | #endif |
1858 | 1822 | |
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 | + | |
1859 | 1863 | #ifdef FEAT_SYN_HL |
1860 | 1864 | if (extra_check && wlv.n_extra == 0) |
1861 | 1865 | { |
@@ -2086,9 +2090,13 @@ | ||
2086 | 2090 | ++wlv.p_extra; |
2087 | 2091 | } |
2088 | 2092 | --wlv.n_extra; |
2089 | -#if defined(FEAT_LINEBREAK) && defined(FEAT_PROP_POPUP) | |
2093 | +#if defined(FEAT_PROP_POPUP) | |
2090 | 2094 | if (wlv.n_extra <= 0) |
2095 | + { | |
2091 | 2096 | in_linebreak = FALSE; |
2097 | + if (search_attr == 0) | |
2098 | + search_attr = saved_search_attr; | |
2099 | + } | |
2092 | 2100 | #endif |
2093 | 2101 | } |
2094 | 2102 | else |
@@ -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| |
@@ -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| |
@@ -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| |
@@ -0,0 +1,6 @@ | ||
1 | +|i+0&#ffffff0|n|s|e|r|t| |s|o|m|e| >t|e|x|t| |(+0fd7ff255|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| |
@@ -0,0 +1,6 @@ | ||
1 | +|i+0&#ffffff0|n|s|e|r|t| |s|o|m|e| >t+0&#ffff4012|e|x|t| |(+0fd7ff255|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| |
@@ -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| |
@@ -2502,6 +2502,42 @@ | ||
2502 | 2502 | call delete('XscriptPropsWithText') |
2503 | 2503 | endfunc |
2504 | 2504 | |
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 | + | |
2505 | 2541 | func Test_props_with_text_after() |
2506 | 2542 | CheckRunVimInTerminal |
2507 | 2543 |
@@ -736,6 +736,8 @@ | ||
736 | 736 | static int included_patches[] = |
737 | 737 | { /* Add new patch number below this line */ |
738 | 738 | /**/ |
739 | + 193, | |
740 | +/**/ | |
739 | 741 | 192, |
740 | 742 | /**/ |
741 | 743 | 191, |