Patch 9.0.0193
Problem:    Search and match highlight 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)
Files:      src/drawline.c, src/testdir/test_textprop.vim,
            src/testdir/dumps/Test_prop_inserts_text_hi_1.dump,
            src/testdir/dumps/Test_prop_inserts_text_hi_2.dump,
            src/testdir/dumps/Test_prop_inserts_text_hi_3.dump,
            src/testdir/dumps/Test_prop_inserts_text_hi_4.dump,
            src/testdir/dumps/Test_prop_inserts_text_hi_5.dump,
            src/testdir/dumps/Test_prop_inserts_text_hi_6.dump


*** ../vim-9.0.0192/src/drawline.c      2022-08-10 20:50:04.233565227 +0100
--- src/drawline.c      2022-08-11 16:56:35.825591821 +0100
***************
*** 558,563 ****
--- 558,565 ----
      int               text_prop_id = 0;       // active property ID
      int               text_prop_flags = 0;
      int               text_prop_follows = FALSE;  // another text prop to 
display
+     int               saved_search_attr = 0;  // search_attr to be used when 
n_extra
+                                       // goes to zero
  #endif
  #ifdef FEAT_SPELL
      int               has_spell = FALSE;      // this buffer has spell 
checking
***************
*** 1583,1628 ****
                        || (noinvcur && (colnr_T)wlv.vcol == wp->w_virtcol)))
                area_attr = 0;                  // stop highlighting
  
- #ifdef FEAT_SEARCH_EXTRA
-           if (!wlv.n_extra)
-           {
-               // Check for start/end of 'hlsearch' and other matches.
-               // After end, check for start/end of next match.
-               // When another match, have to check for start again.
-               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
-               prev_ptr = ptr;
- 
-               // Do not allow a conceal over EOL otherwise EOL will be missed
-               // and bad things happen.
-               if (*ptr == NUL)
-                   has_match_conc = 0;
-           }
- #endif
- 
- #ifdef FEAT_DIFF
-           if (wlv.diff_hlf != (hlf_T)0)
-           {
-               if (wlv.diff_hlf == HLF_CHD && ptr - line >= change_start
-                                                          && wlv.n_extra == 0)
-                   wlv.diff_hlf = HLF_TXD;             // changed text
-               if (wlv.diff_hlf == HLF_TXD && ptr - line > change_end
-                                                          && wlv.n_extra == 0)
-                   wlv.diff_hlf = HLF_CHD;             // changed line
-               line_attr = HL_ATTR(wlv.diff_hlf);
-               if (wp->w_p_cul && lnum == wp->w_cursor.lnum
-                       && wp->w_p_culopt_flags != CULOPT_NBR
-                       && (!wlv.cul_screenline || (wlv.vcol >= left_curline_col
-                                           && wlv.vcol <= right_curline_col)))
-                   line_attr = hl_combine_attr(
-                                         line_attr, HL_ATTR(HLF_CUL));
-           }
- #endif
- 
  #ifdef FEAT_PROP_POPUP
            if (text_props != NULL)
            {
--- 1585,1590 ----
***************
*** 1748,1753 ****
--- 1710,1717 ----
                            wlv.n_extra = (int)STRLEN(p);
                            extra_attr = used_attr;
                            n_attr = mb_charlen(p);
+                           saved_search_attr = search_attr;
+                           search_attr = 0;    // restore when n_extra is zero
                            text_prop_attr = 0;
                            if (*ptr == NUL)
                                // don't combine char attr after EOL
***************
*** 1856,1861 ****
--- 1820,1865 ----
            }
  #endif
  
+ #ifdef FEAT_SEARCH_EXTRA
+           if (wlv.n_extra == 0)
+           {
+               // Check for start/end of 'hlsearch' and other matches.
+               // After end, check for start/end of next match.
+               // When another match, have to check for start again.
+               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
+               prev_ptr = ptr;
+ 
+               // Do not allow a conceal over EOL otherwise EOL will be missed
+               // and bad things happen.
+               if (*ptr == NUL)
+                   has_match_conc = 0;
+           }
+ #endif
+ 
+ #ifdef FEAT_DIFF
+           if (wlv.diff_hlf != (hlf_T)0)
+           {
+               if (wlv.diff_hlf == HLF_CHD && ptr - line >= change_start
+                                                          && wlv.n_extra == 0)
+                   wlv.diff_hlf = HLF_TXD;             // changed text
+               if (wlv.diff_hlf == HLF_TXD && ptr - line > change_end
+                                                          && wlv.n_extra == 0)
+                   wlv.diff_hlf = HLF_CHD;             // changed line
+               line_attr = HL_ATTR(wlv.diff_hlf);
+               if (wp->w_p_cul && lnum == wp->w_cursor.lnum
+                       && wp->w_p_culopt_flags != CULOPT_NBR
+                       && (!wlv.cul_screenline || (wlv.vcol >= left_curline_col
+                                           && wlv.vcol <= right_curline_col)))
+                   line_attr = hl_combine_attr(
+                                         line_attr, HL_ATTR(HLF_CUL));
+           }
+ #endif
+ 
  #ifdef FEAT_SYN_HL
            if (extra_check && wlv.n_extra == 0)
            {
***************
*** 2086,2094 ****
                ++wlv.p_extra;
            }
            --wlv.n_extra;
! #if defined(FEAT_LINEBREAK) && defined(FEAT_PROP_POPUP)
            if (wlv.n_extra <= 0)
                in_linebreak = FALSE;
  #endif
        }
        else
--- 2090,2102 ----
                ++wlv.p_extra;
            }
            --wlv.n_extra;
! #if defined(FEAT_PROP_POPUP)
            if (wlv.n_extra <= 0)
+           {
                in_linebreak = FALSE;
+               if (search_attr == 0)
+                   search_attr = saved_search_attr;
+           }
  #endif
        }
        else
*** ../vim-9.0.0192/src/testdir/test_textprop.vim       2022-08-10 
19:50:44.117894641 +0100
--- src/testdir/test_textprop.vim       2022-08-11 17:22:03.224445207 +0100
***************
*** 2502,2507 ****
--- 2502,2543 ----
    call delete('XscriptPropsWithText')
  endfunc
  
+ func Test_prop_inserts_text_highlight()
+   CheckRunVimInTerminal
+ 
+   " Just a basic check for now
+   let lines =<< trim END
+       call setline(1, 'insert some text (here) and there')
+       call prop_type_add('someprop', #{highlight: 'ErrorMsg'})
+       let bef_prop = prop_add(1, 18, #{type: 'someprop', text: 'BEFORE'})
+       set hlsearch
+       let thematch = matchaddpos("DiffAdd", [[1, 18]])
+       func DoAfter()
+         call prop_remove(#{id: g:bef_prop})
+         call prop_add(1, 19, #{type: 'someprop', text: 'AFTER'})
+         let g:thematch = matchaddpos("DiffAdd", [[1, 18]])
+         let @/ = ''
+       endfunc
+   END
+   call writefile(lines, 'XscriptPropsWithHighlight')
+   let buf = RunVimInTerminal('-S XscriptPropsWithHighlight', #{rows: 6, cols: 
60})
+   call VerifyScreenDump(buf, 'Test_prop_inserts_text_hi_1', {})
+   call term_sendkeys(buf, "/text (he\<CR>")
+   call VerifyScreenDump(buf, 'Test_prop_inserts_text_hi_2', {})
+   call term_sendkeys(buf, ":call matchdelete(thematch)\<CR>")
+   call VerifyScreenDump(buf, 'Test_prop_inserts_text_hi_3', {})
+ 
+   call term_sendkeys(buf, ":call DoAfter()\<CR>")
+   call VerifyScreenDump(buf, 'Test_prop_inserts_text_hi_4', {})
+   call term_sendkeys(buf, "/text (he\<CR>")
+   call VerifyScreenDump(buf, 'Test_prop_inserts_text_hi_5', {})
+   call term_sendkeys(buf, ":call matchdelete(thematch)\<CR>")
+   call VerifyScreenDump(buf, 'Test_prop_inserts_text_hi_6', {})
+ 
+   call StopVimInTerminal(buf)
+   call delete('XscriptPropsWithHighlight')
+ endfunc
+ 
  func Test_props_with_text_after()
    CheckRunVimInTerminal
  
*** ../vim-9.0.0192/src/testdir/dumps/Test_prop_inserts_text_hi_1.dump  
2022-08-11 17:24:05.213611374 +0100
--- src/testdir/dumps/Test_prop_inserts_text_hi_1.dump  2022-08-11 
17:22:07.972496120 +0100
***************
*** 0 ****
--- 1,6 ----
+ >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
+ |~+0#4040ff13&| @58
+ |~| @58
+ |~| @58
+ |~| @58
+ | +0#0000000&@41|1|,|1| @10|A|l@1| 
*** ../vim-9.0.0192/src/testdir/dumps/Test_prop_inserts_text_hi_2.dump  
2022-08-11 17:24:05.217611408 +0100
--- src/testdir/dumps/Test_prop_inserts_text_hi_2.dump  2022-08-11 
17:22:09.128508441 +0100
***************
*** 0 ****
--- 1,6 ----
+ |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
+ |~+0#4040ff13&| @58
+ |~| @58
+ |~| @58
+ |~| @58
+ |/+0#0000000&|t|e|x|t| |(|h|e| @32|1|,|1|3| @9|A|l@1| 
*** ../vim-9.0.0192/src/testdir/dumps/Test_prop_inserts_text_hi_3.dump  
2022-08-11 17:24:05.221611440 +0100
--- src/testdir/dumps/Test_prop_inserts_text_hi_3.dump  2022-08-11 
17:22:10.276520651 +0100
***************
*** 0 ****
--- 1,6 ----
+ |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
+ |~+0#4040ff13&| @58
+ |~| @58
+ |~| @58
+ |~| @58
+ |:+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| 
*** ../vim-9.0.0192/src/testdir/dumps/Test_prop_inserts_text_hi_4.dump  
2022-08-11 17:24:05.225611477 +0100
--- src/testdir/dumps/Test_prop_inserts_text_hi_4.dump  2022-08-11 
17:22:11.428532871 +0100
***************
*** 0 ****
--- 1,6 ----
+ |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
+ |~+0#4040ff13&| @58
+ |~| @58
+ |~| @58
+ |~| @58
+ |:+0#0000000&|c|a|l@1| |D|o|A|f|t|e|r|(|)| @26|1|,|1|3| @9|A|l@1| 
*** ../vim-9.0.0192/src/testdir/dumps/Test_prop_inserts_text_hi_5.dump  
2022-08-11 17:24:05.225611477 +0100
--- src/testdir/dumps/Test_prop_inserts_text_hi_5.dump  2022-08-11 
17:22:12.580545066 +0100
***************
*** 0 ****
--- 1,6 ----
+ |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
+ |~+0#4040ff13&| @58
+ |~| @58
+ |~| @58
+ |~| @58
+ |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| 
*** ../vim-9.0.0192/src/testdir/dumps/Test_prop_inserts_text_hi_6.dump  
2022-08-11 17:24:05.229611511 +0100
--- src/testdir/dumps/Test_prop_inserts_text_hi_6.dump  2022-08-11 
17:22:13.736557278 +0100
***************
*** 0 ****
--- 1,6 ----
+ |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
+ |~+0#4040ff13&| @58
+ |~| @58
+ |~| @58
+ |~| @58
+ |:+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| 
*** ../vim-9.0.0192/src/version.c       2022-08-11 15:52:10.576940817 +0100
--- src/version.c       2022-08-11 17:00:02.153086314 +0100
***************
*** 737,738 ****
--- 737,740 ----
  {   /* Add new patch number below this line */
+ /**/
+     193,
  /**/

-- 
DINGO: Wicked wicked Zoot ... she is a bad person and she must pay the
       penalty.  And here in Castle Anthrax, we have but one punishment
       ... you must tie her down on a bed ... and spank her.  Come!
GIRLS: A spanking!  A spanking!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// 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/20220811162746.4E9C81C4F14%40moolenaar.net.

Raspunde prin e-mail lui