Patch 9.0.1325
Problem:    'colorcolumn' highlight wrong with virtual text above.
Solution:   Adjust column of 'colorcolumn' for text propertly. (closes #12004)
Files:      src/drawline.c, src/testdir/test_textprop.vim,
            src/testdir/dumps/Test_prop_above_below_empty_3.dump


*** ../vim-9.0.1324/src/drawline.c      2023-02-12 14:41:58.060651001 +0000
--- src/drawline.c      2023-02-19 14:10:21.535896501 +0000
***************
*** 96,103 ****
  #ifdef FEAT_CONCEAL
      int               boguscols;      // nonexistent columns added to "col" 
to force
                                // wrapping
!     int               vcol_off;       // offset for concealed characters
  #endif
  #ifdef FEAT_SYN_HL
      int               draw_color_col; // highlight colorcolumn
      int               *color_cols;    // pointer to according columns array
--- 96,104 ----
  #ifdef FEAT_CONCEAL
      int               boguscols;      // nonexistent columns added to "col" 
to force
                                // wrapping
!     int               vcol_off_co;    // offset for concealed characters
  #endif
+     int               vcol_off_tp;    // offset for virtual text
  #ifdef FEAT_SYN_HL
      int               draw_color_col; // highlight colorcolumn
      int               *color_cols;    // pointer to according columns array
***************
*** 839,847 ****
      // edge for 'cursorcolumn'.
      wlv->col -= wlv->boguscols;
      wlv->boguscols = 0;
! #  define VCOL_HLC (wlv->vcol - wlv->vcol_off)
  # else
! #  define VCOL_HLC (wlv->vcol)
  # endif
  
      if (wlv->draw_color_col)
--- 840,848 ----
      // edge for 'cursorcolumn'.
      wlv->col -= wlv->boguscols;
      wlv->boguscols = 0;
! #  define VCOL_HLC (wlv->vcol - wlv->vcol_off_co - wlv->vcol_off_tp)
  # else
! #  define VCOL_HLC (wlv->vcol - wlv->vcol_off_tp)
  # endif
  
      if (wlv->draw_color_col)
***************
*** 1177,1194 ****
      int               is_concealing   = FALSE;
      int               did_wcol        = FALSE;
      int               old_boguscols   = 0;
! # define VCOL_HLC (wlv.vcol - wlv.vcol_off)
  # define FIX_FOR_BOGUSCOLS \
      { \
!       wlv.n_extra += wlv.vcol_off; \
!       wlv.vcol -= wlv.vcol_off; \
!       wlv.vcol_off = 0; \
        wlv.col -= wlv.boguscols; \
        old_boguscols = wlv.boguscols; \
        wlv.boguscols = 0; \
      }
  #else
! # define VCOL_HLC (wlv.vcol)
  #endif
  
      if (startrow > endrow)            // past the end already!
--- 1178,1195 ----
      int               is_concealing   = FALSE;
      int               did_wcol        = FALSE;
      int               old_boguscols   = 0;
! # define VCOL_HLC (wlv.vcol - wlv.vcol_off_co - wlv.vcol_off_tp)
  # define FIX_FOR_BOGUSCOLS \
      { \
!       wlv.n_extra += wlv.vcol_off_co; \
!       wlv.vcol -= wlv.vcol_off_co; \
!       wlv.vcol_off_co = 0; \
        wlv.col -= wlv.boguscols; \
        old_boguscols = wlv.boguscols; \
        wlv.boguscols = 0; \
      }
  #else
! # define VCOL_HLC (wlv.vcol - wlv.vcol_off_tp)
  #endif
  
      if (startrow > endrow)            // past the end already!
***************
*** 1864,1870 ****
        // When only displaying the (relative) line number and that's done,
        // stop here.
        if (((dollar_vcol >= 0 && wp == curwin
!                  && lnum == wp->w_cursor.lnum && wlv.vcol >= 
(long)wp->w_virtcol)
                || (number_only && wlv.draw_state > WL_NR))
  #ifdef FEAT_DIFF
                                   && wlv.filler_todo <= 0
--- 1865,1872 ----
        // When only displaying the (relative) line number and that's done,
        // stop here.
        if (((dollar_vcol >= 0 && wp == curwin
!                              && lnum == wp->w_cursor.lnum
!                              && wlv.vcol >= (long)wp->w_virtcol)
                || (number_only && wlv.draw_state > WL_NR))
  #ifdef FEAT_DIFF
                                   && wlv.filler_todo <= 0
***************
*** 2123,2128 ****
--- 2125,2133 ----
                                    p_extra_free2 = wlv.p_extra;
                                }
  
+                               if (above)
+                                   wlv.vcol_off_tp = wlv.n_extra;
+ 
                                if (lcs_eol_one < 0
                                        && wp->w_p_wrap
                                        && wlv.col
***************
*** 2991,2999 ****
                        int     saved_nextra = wlv.n_extra;
  
  # ifdef FEAT_CONCEAL
!                       if (wlv.vcol_off > 0)
                            // there are characters to conceal
!                           tab_len += wlv.vcol_off;
  
                        // boguscols before FIX_FOR_BOGUSCOLS macro from above
                        if (wp->w_p_list && wp->w_lcs_chars.tab1
--- 2996,3004 ----
                        int     saved_nextra = wlv.n_extra;
  
  # ifdef FEAT_CONCEAL
!                       if (wlv.vcol_off_co > 0)
                            // there are characters to conceal
!                           tab_len += wlv.vcol_off_co;
  
                        // boguscols before FIX_FOR_BOGUSCOLS macro from above
                        if (wp->w_p_list && wp->w_lcs_chars.tab1
***************
*** 3047,3054 ****
                                // n_extra will be increased by
                                // FIX_FOX_BOGUSCOLS macro below, so need to
                                // adjust for that here
!                               if (wlv.vcol_off > 0)
!                                   wlv.n_extra -= wlv.vcol_off;
  # endif
                            }
                        }
--- 3052,3059 ----
                                // n_extra will be increased by
                                // FIX_FOX_BOGUSCOLS macro below, so need to
                                // adjust for that here
!                               if (wlv.vcol_off_co > 0)
!                                   wlv.n_extra -= wlv.vcol_off_co;
  # endif
                            }
                        }
***************
*** 3056,3067 ****
  #endif
  #ifdef FEAT_CONCEAL
                    {
!                       int vc_saved = wlv.vcol_off;
  
                        // Tab alignment should be identical regardless of
                        // 'conceallevel' value. So tab compensates of all
                        // previous concealed characters, and thus resets
!                       // vcol_off and boguscols accumulated so far in the
                        // line. Note that the tab can be longer than
                        // 'tabstop' when there are concealed characters.
                        FIX_FOR_BOGUSCOLS;
--- 3061,3072 ----
  #endif
  #ifdef FEAT_CONCEAL
                    {
!                       int vc_saved = wlv.vcol_off_co;
  
                        // Tab alignment should be identical regardless of
                        // 'conceallevel' value. So tab compensates of all
                        // previous concealed characters, and thus resets
!                       // vcol_off_co and boguscols accumulated so far in the
                        // line. Note that the tab can be longer than
                        // 'tabstop' when there are concealed characters.
                        FIX_FOR_BOGUSCOLS;
***************
*** 3326,3332 ****
                    prev_syntax_id = syntax_seqnr;
  
                    if (wlv.n_extra > 0)
!                       wlv.vcol_off += wlv.n_extra;
                    wlv.vcol += wlv.n_extra;
                    if (wp->w_p_wrap && wlv.n_extra > 0)
                    {
--- 3331,3337 ----
                    prev_syntax_id = syntax_seqnr;
  
                    if (wlv.n_extra > 0)
!                       wlv.vcol_off_co += wlv.n_extra;
                    wlv.vcol += wlv.n_extra;
                    if (wp->w_p_wrap && wlv.n_extra > 0)
                    {
***************
*** 3800,3808 ****
        else if (wp->w_p_cole > 0 && is_concealing)
        {
            --n_skip;
!           ++wlv.vcol_off;
            if (wlv.n_extra > 0)
!               wlv.vcol_off += wlv.n_extra;
            if (wp->w_p_wrap)
            {
                // Special voodoo required if 'wrap' is on.
--- 3805,3813 ----
        else if (wp->w_p_cole > 0 && is_concealing)
        {
            --n_skip;
!           ++wlv.vcol_off_co;
            if (wlv.n_extra > 0)
!               wlv.vcol_off_co += wlv.n_extra;
            if (wp->w_p_wrap)
            {
                // Special voodoo required if 'wrap' is on.
***************
*** 3895,3901 ****
            wlv.char_attr = vcol_save_attr;
  #endif
  
!       // restore attributes after "predeces" in 'listchars'
        if (wlv.draw_state > WL_NR && n_attr3 > 0 && --n_attr3 == 0)
            wlv.char_attr = saved_attr3;
  
--- 3900,3906 ----
            wlv.char_attr = vcol_save_attr;
  #endif
  
!       // restore attributes after "precedes" in 'listchars'
        if (wlv.draw_state > WL_NR && n_attr3 > 0 && --n_attr3 == 0)
            wlv.char_attr = saved_attr3;
  
***************
*** 3932,3938 ****
            wlv_screen_line(wp, &wlv, FALSE);
            wlv.col += wlv.boguscols;
            wlv.boguscols = 0;
!           wlv.vcol_off = 0;
  #else
            wlv_screen_line(wp, &wlv, FALSE);
  #endif
--- 3937,3943 ----
            wlv_screen_line(wp, &wlv, FALSE);
            wlv.col += wlv.boguscols;
            wlv.boguscols = 0;
!           wlv.vcol_off_co = 0;
  #else
            wlv_screen_line(wp, &wlv, FALSE);
  #endif
*** ../vim-9.0.1324/src/testdir/test_textprop.vim       2023-02-12 
18:11:03.678422979 +0000
--- src/testdir/test_textprop.vim       2023-02-19 14:12:03.764207449 +0000
***************
*** 2801,2806 ****
--- 2801,2811 ----
    call term_sendkeys(buf, ":set list\<CR>")
    call VerifyScreenDump(buf, 'Test_prop_above_below_empty_2', {})
  
+   call term_sendkeys(buf, ":set nolist\<CR>")
+   call term_sendkeys(buf, ":set colorcolumn=10\<CR>")
+   call term_sendkeys(buf, ":\<CR>")
+   call VerifyScreenDump(buf, 'Test_prop_above_below_empty_3', {})
+ 
    call StopVimInTerminal(buf)
  endfunc
  
*** ../vim-9.0.1324/src/testdir/dumps/Test_prop_above_below_empty_3.dump        
2023-02-19 14:14:39.080614006 +0000
--- src/testdir/dumps/Test_prop_above_below_empty_3.dump        2023-02-19 
14:12:15.304242103 +0000
***************
*** 0 ****
--- 1,16 ----
+ | +0#af5f00255#ffffff0@3|-+0#0000001#ffff4012@2| +0#0000000#ffffff0@52
+ | +0#af5f00255&@1|1| |1+0#0000000&@7| | +0&#ffd7d7255| +0&#ffffff0@45
+ | +0#af5f00255&@3|++0#0000001#ffff4012@2| +0#0000000#ffffff0@52
+ | +0#af5f00255&@3|-+0#0000001#ffff4012@2| +0#0000000#ffffff0@52
+ | +0#af5f00255&@1|2| | +0#0000000&@8| +0&#ffd7d7255| +0&#ffffff0@45
+ | +0#af5f00255&@3|++0#0000001#ffff4012@2| +0#0000000#ffffff0@52
+ | +0#af5f00255&@3|-+0#0000001#ffff4012@2| +0#0000000#ffffff0@52
+ | +0#af5f00255&@1|3| |3+0#0000000&@8| +0&#ffd7d7255| +0&#ffffff0@45
+ | +0#af5f00255&@3|++0#0000001#ffff4012@2| +0#0000000#ffffff0@52
+ | +0#af5f00255&@3|-+0#0000001#ffff4012@2| +0#0000000#ffffff0@52
+ | +0#af5f00255&@1|4| | +0#0000000&@8| +0&#ffd7d7255| +0&#ffffff0@45
+ | +0#af5f00255&@3|++0#0000001#ffff4012@2| +0#0000000#ffffff0@52
+ | +0#af5f00255&@3|-+0#0000001#ffff4012@2| +0#0000000#ffffff0@52
+ | +0#af5f00255&@1|5| >5+0#0000000&@8|5+0&#ffd7d7255|5+0&#ffffff0| @44
+ | +0#af5f00255&@3|++0#0000001#ffff4012@2| +0#0000000#ffffff0@52
+ |:| @40|5|,|1|-|5|7| @7|A|l@1| 
*** ../vim-9.0.1324/src/version.c       2023-02-18 20:15:39.693994664 +0000
--- src/version.c       2023-02-19 14:09:46.835924892 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1325,
  /**/

-- 
You are not really successful until someone claims he sat
beside you in school.

 /// 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/20230219141631.068E71C07A0%40moolenaar.net.

Raspunde prin e-mail lui