Patch 9.0.0452
Problem:    Visual highlighting extends into virtual text prop.
Solution:   Do not highlight what isn't actually selected.  Fix ordering of
            stored text props.
Files:      src/drawline.c, src/textprop.c, src/testdir/test_textprop.vim,
            src/testdir/dumps/Test_prop_with_text_above_6.dump,
            src/testdir/dumps/Test_prop_with_text_above_7.dump


*** ../vim-9.0.0451/src/drawline.c      2022-09-12 17:50:42.778378272 +0100
--- src/drawline.c      2022-09-12 18:22:55.070293258 +0100
***************
*** 670,675 ****
--- 670,676 ----
      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
+     int               saved_area_attr = 0;    // idem for area_attr
  #endif
  #ifdef FEAT_SPELL
      int               has_spell = FALSE;      // this buffer has spell 
checking
***************
*** 1846,1853 ****
                            extra_for_textprop = TRUE;
                            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;
                            text_prop_attr_comb = 0;
                            if (*ptr == NUL)
--- 1847,1858 ----
                            extra_for_textprop = TRUE;
                            extra_attr = used_attr;
                            n_attr = mb_charlen(p);
+                           // restore search_attr and area_attr when n_extra
+                           // is down to zero
                            saved_search_attr = search_attr;
!                           saved_area_attr = area_attr;
!                           search_attr = 0;
!                           area_attr = 0;
                            text_prop_attr = 0;
                            text_prop_attr_comb = 0;
                            if (*ptr == NUL)
***************
*** 2203,2208 ****
--- 2208,2215 ----
                in_linebreak = FALSE;
                if (search_attr == 0)
                    search_attr = saved_search_attr;
+               if (area_attr == 0 && *ptr != NUL)
+                   area_attr = saved_area_attr;
            }
  #endif
        }
*** ../vim-9.0.0451/src/textprop.c      2022-09-12 17:50:42.782378262 +0100
--- src/textprop.c      2022-09-12 19:19:22.148921298 +0100
***************
*** 232,239 ****
  
      for (lnum = start_lnum; lnum <= end_lnum; ++lnum)
      {
!       colnr_T col;    // start column
!       long    length; // in bytes
  
        // Fetch the line to get the ml_line_len field updated.
        proplen = get_text_props(buf, lnum, &props, TRUE);
--- 232,240 ----
  
      for (lnum = start_lnum; lnum <= end_lnum; ++lnum)
      {
!       colnr_T col;        // start column use in tp_col
!       colnr_T sort_col;   // column where it appears
!       long    length;     // in bytes
  
        // Fetch the line to get the ml_line_len field updated.
        proplen = get_text_props(buf, lnum, &props, TRUE);
***************
*** 248,253 ****
--- 249,255 ----
            semsg(_(e_invalid_column_number_nr), (long)start_col);
            goto theend;
        }
+       sort_col = col;
  
        if (lnum == end_lnum)
            length = end_col - col;
***************
*** 263,269 ****
            length = 1;         // text is placed on one character
            if (col == 0)
            {
!               col = MAXCOL;   // after the line
                length += text_padding_left;
            }
        }
--- 265,273 ----
            length = 1;         // text is placed on one character
            if (col == 0)
            {
!               col = MAXCOL;   // before or after the line
!               if ((text_flags & TP_FLAG_ALIGN_ABOVE) == 0)
!                   sort_col = MAXCOL;
                length += text_padding_left;
            }
        }
***************
*** 280,288 ****
        // the text, we need to copy them as bytes before using it as a struct.
        for (i = 0; i < proplen; ++i)
        {
            mch_memmove(&tmp_prop, props + i * sizeof(textprop_T),
                                                           sizeof(textprop_T));
!           if (tmp_prop.tp_col >= col)
                break;
        }
        newprops = newtext + textlen;
--- 284,298 ----
        // the text, we need to copy them as bytes before using it as a struct.
        for (i = 0; i < proplen; ++i)
        {
+           colnr_T prop_col;
+ 
            mch_memmove(&tmp_prop, props + i * sizeof(textprop_T),
                                                           sizeof(textprop_T));
!           // col is MAXCOL when the text goes above or after the line, when
!           // above we should use column zero for sorting
!           prop_col = (tmp_prop.tp_flags & TP_FLAG_ALIGN_ABOVE)
!                               ? 0 : tmp_prop.tp_col;
!           if (prop_col >= sort_col)
                break;
        }
        newprops = newtext + textlen;
*** ../vim-9.0.0451/src/testdir/test_textprop.vim       2022-09-12 
17:50:42.782378262 +0100
--- src/testdir/test_textprop.vim       2022-09-12 18:27:43.117556840 +0100
***************
*** 2855,2865 ****
--- 2855,2869 ----
        call setline(1, ['one two', 'three four', 'five six'])
        call prop_type_add('above1', #{highlight: 'Search'})
        call prop_type_add('above2', #{highlight: 'DiffChange'})
+       call prop_type_add('below', #{highlight: 'DiffAdd'})
        call prop_add(1, 0, #{type: 'above1', text: 'first thing above', 
text_align: 'above'})
        call prop_add(1, 0, #{type: 'above2', text: 'second thing above', 
text_align: 'above'})
        call prop_add(3, 0, #{type: 'above1', text: 'another thing', 
text_align: 'above', text_padding_left: 3})
  
        normal gglllj
+       func AddPropBelow()
+         call prop_add(1, 0, #{type: 'below', text: 'below', text_align: 
'below'})
+       endfunc
    END
    call writefile(lines, 'XscriptPropsWithTextAbove', 'D')
    let buf = RunVimInTerminal('-S XscriptPropsWithTextAbove', #{rows: 9, cols: 
60})
***************
*** 2876,2881 ****
--- 2880,2891 ----
    call term_sendkeys(buf, ":set nowrap\<CR>gg$j")
    call VerifyScreenDump(buf, 'Test_prop_with_text_above_5', {})
  
+   call term_sendkeys(buf, ":call AddPropBelow()\<CR>")
+   call term_sendkeys(buf, "ggve")
+   call VerifyScreenDump(buf, 'Test_prop_with_text_above_6', {})
+   call term_sendkeys(buf, "V")
+   call VerifyScreenDump(buf, 'Test_prop_with_text_above_7', {})
+ 
    call StopVimInTerminal(buf)
  endfunc
  
*** ../vim-9.0.0451/src/testdir/dumps/Test_prop_with_text_above_6.dump  
2022-09-12 19:22:57.544331573 +0100
--- src/testdir/dumps/Test_prop_with_text_above_6.dump  2022-09-12 
19:19:31.432895808 +0100
***************
*** 0 ****
--- 1,9 ----
+ | +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@1|1| 
|f+0#0000000#ffff4012|i|r|s|t| |t|h|i|n|g| |a|b|o|v|e| @36
+ | +0#0000e05#a8a8a8255@1| 
+0#af5f00255#ffffff0@3|s+0#0000000#ffd7ff255|e|c|o|n|d| |t|h|i|n|g| |a|b|o|v|e| 
@35
+ | +0#0000e05#a8a8a8255@1| 
+0#af5f00255#ffffff0@3|i+0#0000000#e0e0e08|n|s|e|r|t|e>d+0&#ffffff0| |o|n|e| 
|t|w|o| @37
+ | +0#0000e05#a8a8a8255@1| 
+0#af5f00255#ffffff0@3|b+0#0000000#5fd7ff255|e|l|o|w| +0&#ffffff0@48
+ | +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@1|2| |t+0#0000000&|h|r|e@1| 
|f|o|u|r| @43
+ | +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@1|3| | 
+0#0000000&@2|a+0&#ffff4012|n|o|t|h|e|r| |t|h|i|n|g| @37
+ | +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@3|f+0#0000000&|i|v|e| |s|i|x| 
@45
+ |~+0#4040ff13&| @58
+ |-+2#0000000&@1| |V|I|S|U|A|L| |-@1| +0&&@19|8| @8|1|,|8|-|1@1|6| @6|A|l@1| 
*** ../vim-9.0.0451/src/testdir/dumps/Test_prop_with_text_above_7.dump  
2022-09-12 19:22:57.548331562 +0100
--- src/testdir/dumps/Test_prop_with_text_above_7.dump  2022-09-12 
19:19:32.592892623 +0100
***************
*** 0 ****
--- 1,9 ----
+ | +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@1|1| 
|f+0#0000000#ffff4012|i|r|s|t| |t|h|i|n|g| |a|b|o|v|e| @36
+ | +0#0000e05#a8a8a8255@1| 
+0#af5f00255#ffffff0@3|s+0#0000000#ffd7ff255|e|c|o|n|d| |t|h|i|n|g| |a|b|o|v|e| 
@35
+ | +0#0000e05#a8a8a8255@1| 
+0#af5f00255#ffffff0@3|i+0#0000000#e0e0e08|n|s|e|r|t|e>d+0&#ffffff0| 
+0&#e0e0e08|o|n|e| |t|w|o| +0&#ffffff0@37
+ | +0#0000e05#a8a8a8255@1| 
+0#af5f00255#ffffff0@3|b+0#0000000#5fd7ff255|e|l|o|w| +0#4040ff13#ffffff0| 
+0#0000000&@47
+ | +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@1|2| |t+0#0000000&|h|r|e@1| 
|f|o|u|r| @43
+ | +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@1|3| | 
+0#0000000&@2|a+0&#ffff4012|n|o|t|h|e|r| |t|h|i|n|g| @37
+ | +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@3|f+0#0000000&|i|v|e| |s|i|x| 
@45
+ |~+0#4040ff13&| @58
+ |-+2#0000000&@1| |V|I|S|U|A|L| |L|I|N|E| |-@1| +0&&@14|1| @8|1|,|8|-|1@1|6| 
@6|A|l@1| 
*** ../vim-9.0.0451/src/version.c       2022-09-12 17:50:42.782378262 +0100
--- src/version.c       2022-09-12 19:20:56.940661368 +0100
***************
*** 705,706 ****
--- 705,708 ----
  {   /* Add new patch number below this line */
+ /**/
+     452,
  /**/

-- 
Never go to the toilet in a paperless office.

 /// Bram Moolenaar -- b...@moolenaar.net -- 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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220912182556.B08B71C0CFD%40moolenaar.net.

Raspunde prin e-mail lui