Patch 9.0.0982
Problem:    'cursorline' not drawn before virtual text below.
Solution:   Add the 'cursorline' attribute to the empty space. (closes #11647)
Files:      src/drawline.c, src/testdir/test_textprop.vim,
            src/testdir/dumps/Test_prop_with_text_below_cul_1.dump


*** ../vim-9.0.0981/src/drawline.c      2022-11-29 21:36:52.130387013 +0000
--- src/drawline.c      2022-12-01 18:36:18.714922385 +0000
***************
*** 75,80 ****
--- 75,86 ----
  }
  #endif
  
+ #if defined(FEAT_SIGNS) || defined(FEAT_QUICKFIX) \
+       || defined(FEAT_SYN_HL) || defined(FEAT_DIFF)
+ // using an attribute for the whole line
+ # define LINE_ATTR
+ #endif
+ 
  // structure with variables passed between win_line() and other functions
  typedef struct {
      int               draw_state;     // what to draw next
***************
*** 106,111 ****
--- 112,120 ----
  #ifdef FEAT_SYN_HL
      int               cul_attr;       // set when 'cursorline' active
  #endif
+ #ifdef LINE_ATTR
+     int               line_attr;      // for the whole line, includes 
'cursorline'
+ #endif
  
      int               screen_line_flags;  // flags for screen_line()
  
***************
*** 848,855 ****
                    && (int)wp->w_virtcol <
                         (long)wp->w_width * (wlv->row - wlv->startrow + 1) + v
                         && wlv->lnum != wp->w_cursor.lnum)
!           || wlv->draw_color_col
!           || wlv->win_attr != 0)
  # ifdef FEAT_RIGHTLEFT
            && !wp->w_p_rl
  # endif
--- 857,867 ----
                    && (int)wp->w_virtcol <
                         (long)wp->w_width * (wlv->row - wlv->startrow + 1) + v
                         && wlv->lnum != wp->w_cursor.lnum)
!               || wlv->draw_color_col
! # ifdef LINE_ATTR
!               || wlv->line_attr != 0
! # endif
!               || wlv->win_attr != 0)
  # ifdef FEAT_RIGHTLEFT
            && !wp->w_p_rl
  # endif
***************
*** 877,890 ****
                wlv->draw_color_col = advance_color_col(
                                                   VCOL_HLC, &wlv->color_cols);
  
            if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol)
!               ScreenAttrs[wlv->off++] = HL_ATTR(HLF_CUC);
            else if (wlv->draw_color_col && VCOL_HLC == *wlv->color_cols)
!               ScreenAttrs[wlv->off++] = HL_ATTR(HLF_MC);
!           else
!               ScreenAttrs[wlv->off++] = wlv->win_attr;
  
!           if (VCOL_HLC >= rightmost_vcol && wlv->win_attr == 0)
                break;
  
            ++wlv->vcol;
--- 889,910 ----
                wlv->draw_color_col = advance_color_col(
                                                   VCOL_HLC, &wlv->color_cols);
  
+           int attr = wlv->win_attr;
            if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol)
!               attr = HL_ATTR(HLF_CUC);
            else if (wlv->draw_color_col && VCOL_HLC == *wlv->color_cols)
!               attr = HL_ATTR(HLF_MC);
! # ifdef LINE_ATTR
!           else if (wlv->line_attr != 0)
!               attr = wlv->line_attr;
! # endif
!           ScreenAttrs[wlv->off++] = attr;
  
!           if (VCOL_HLC >= rightmost_vcol
! # ifdef LINE_ATTR
!                   && wlv->line_attr == 0
! # endif
!                   && wlv->win_attr == 0)
                break;
  
            ++wlv->vcol;
***************
*** 1085,1094 ****
      colnr_T   leadcol = 0;            // start of leading spaces
      int               in_multispace = FALSE;  // in multiple consecutive 
spaces
      int               multispace_pos = 0;     // position in lcs-multispace 
string
! #if defined(FEAT_SIGNS) || defined(FEAT_QUICKFIX) \
!       || defined(FEAT_SYN_HL) || defined(FEAT_DIFF)
! # define LINE_ATTR
!     int               line_attr = 0;          // attribute for the whole line
      int               line_attr_save = 0;
  #endif
      int               sign_present = FALSE;
--- 1105,1111 ----
      colnr_T   leadcol = 0;            // start of leading spaces
      int               in_multispace = FALSE;  // in multiple consecutive 
spaces
      int               multispace_pos = 0;     // position in lcs-multispace 
string
! #ifdef LINE_ATTR
      int               line_attr_save = 0;
  #endif
      int               sign_present = FALSE;
***************
*** 1392,1407 ****
  
  #ifdef LINE_ATTR
  # ifdef FEAT_SIGNS
!     // If this line has a sign with line highlighting set line_attr.
      if (sign_present)
!       line_attr = wlv.sattr.sat_linehl;
  # endif
  # if defined(FEAT_QUICKFIX)
      // Highlight the current line in the quickfix window.
      if (bt_quickfix(wp->w_buffer) && qf_current_entry(wp) == lnum)
!       line_attr = HL_ATTR(HLF_QFL);
  # endif
!     if (line_attr != 0)
        area_highlighting = TRUE;
  #endif
  
--- 1409,1424 ----
  
  #ifdef LINE_ATTR
  # ifdef FEAT_SIGNS
!     // If this line has a sign with line highlighting set wlv.line_attr.
      if (sign_present)
!       wlv.line_attr = wlv.sattr.sat_linehl;
  # endif
  # if defined(FEAT_QUICKFIX)
      // Highlight the current line in the quickfix window.
      if (bt_quickfix(wp->w_buffer) && qf_current_entry(wp) == lnum)
!       wlv.line_attr = HL_ATTR(HLF_QFL);
  # endif
!     if (wlv.line_attr != 0)
        area_highlighting = TRUE;
  #endif
  
***************
*** 1651,1657 ****
            wlv.cul_screenline = (wp->w_p_wrap
                                   && (wp->w_p_culopt_flags & CULOPT_SCRLINE));
  
!           // Only set line_attr here when "screenline" is not present in
            // 'cursorlineopt'.  Otherwise it's done later.
            if (!wlv.cul_screenline)
            {
--- 1668,1674 ----
            wlv.cul_screenline = (wp->w_p_wrap
                                   && (wp->w_p_culopt_flags & CULOPT_SCRLINE));
  
!           // Only set wlv.line_attr here when "screenline" is not present in
            // 'cursorlineopt'.  Otherwise it's done later.
            if (!wlv.cul_screenline)
            {
***************
*** 1662,1670 ****
                if (sign_present && wlv.sattr.sat_linehl > 0)
                {
                    if (wlv.sattr.sat_priority >= 100)
!                       line_attr = hl_combine_attr(wlv.cul_attr, line_attr);
                    else
!                       line_attr = hl_combine_attr(line_attr, wlv.cul_attr);
                }
                else
  # endif
--- 1679,1689 ----
                if (sign_present && wlv.sattr.sat_linehl > 0)
                {
                    if (wlv.sattr.sat_priority >= 100)
!                       wlv.line_attr = hl_combine_attr(
!                                                 wlv.cul_attr, wlv.line_attr);
                    else
!                       wlv.line_attr = hl_combine_attr(
!                                                 wlv.line_attr, wlv.cul_attr);
                }
                else
  # endif
***************
*** 1672,1685 ****
                    // let the line attribute overrule 'cursorline', otherwise
                    // it disappears when both have background set;
                    // 'cursorline' can use underline or bold to make it show
!                   line_attr = hl_combine_attr(wlv.cul_attr, line_attr);
  # else
!                   line_attr = wlv.cul_attr;
  # endif
            }
            else
            {
!               line_attr_save = line_attr;
                margin_columns_win(wp, &left_curline_col, &right_curline_col);
            }
            area_highlighting = TRUE;
--- 1691,1705 ----
                    // let the line attribute overrule 'cursorline', otherwise
                    // it disappears when both have background set;
                    // 'cursorline' can use underline or bold to make it show
!                   wlv.line_attr = hl_combine_attr(
!                                                 wlv.cul_attr, wlv.line_attr);
  # else
!                   wlv.line_attr = wlv.cul_attr;
  # endif
            }
            else
            {
!               line_attr_save = wlv.line_attr;
                margin_columns_win(wp, &left_curline_col, &right_curline_col);
            }
            area_highlighting = TRUE;
***************
*** 1741,1747 ****
            if (wlv.cul_screenline)
            {
                wlv.cul_attr = 0;
!               line_attr = line_attr_save;
            }
  #endif
            if (wlv.draw_state == WL_CMDLINE - 1 && wlv.n_extra == 0)
--- 1761,1767 ----
            if (wlv.cul_screenline)
            {
                wlv.cul_attr = 0;
!               wlv.line_attr = line_attr_save;
            }
  #endif
            if (wlv.draw_state == WL_CMDLINE - 1 && wlv.n_extra == 0)
***************
*** 1805,1811 ****
                && wlv.vcol < right_curline_col)
        {
            wlv.cul_attr = HL_ATTR(HLF_CUL);
!           line_attr = wlv.cul_attr;
        }
  #endif
  
--- 1825,1831 ----
                && wlv.vcol < right_curline_col)
        {
            wlv.cul_attr = HL_ATTR(HLF_CUL);
!           wlv.line_attr = wlv.cul_attr;
        }
  #endif
  
***************
*** 2161,2173 ****
                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
  
--- 2181,2193 ----
                if (wlv.diff_hlf == HLF_TXD && ptr - line > change_end
                                                           && wlv.n_extra == 0)
                    wlv.diff_hlf = HLF_CHD;             // changed line
!               wlv.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)))
!                   wlv.line_attr = hl_combine_attr(
!                                         wlv.line_attr, HL_ATTR(HLF_CUL));
            }
  #endif
  
***************
*** 2251,2257 ****
  #ifdef LINE_ATTR
            if (area_attr != 0)
            {
!               wlv.char_attr = hl_combine_attr(line_attr, area_attr);
                if (!highlight_match)
                    // let search highlight show in Visual area if possible
                    wlv.char_attr = hl_combine_attr(search_attr, wlv.char_attr);
--- 2271,2277 ----
  #ifdef LINE_ATTR
            if (area_attr != 0)
            {
!               wlv.char_attr = hl_combine_attr(wlv.line_attr, area_attr);
                if (!highlight_match)
                    // let search highlight show in Visual area if possible
                    wlv.char_attr = hl_combine_attr(search_attr, wlv.char_attr);
***************
*** 2261,2283 ****
            }
            else if (search_attr != 0)
            {
!               wlv.char_attr = hl_combine_attr(line_attr, search_attr);
  # ifdef FEAT_SYN_HL
                wlv.char_attr = hl_combine_attr(syntax_attr, wlv.char_attr);
  # endif
            }
!           else if (line_attr != 0
                    && ((wlv.fromcol == -10 && wlv.tocol == MAXCOL)
                              || wlv.vcol < wlv.fromcol
                              || vcol_prev < fromcol_prev
                              || wlv.vcol >= wlv.tocol))
            {
!               // Use line_attr when not in the Visual or 'incsearch' area
                // (area_attr may be 0 when "noinvcur" is set).
  # ifdef FEAT_SYN_HL
!               wlv.char_attr = hl_combine_attr(syntax_attr, line_attr);
  # else
!               wlv.char_attr = line_attr;
  # endif
                attr_pri = FALSE;
            }
--- 2281,2303 ----
            }
            else if (search_attr != 0)
            {
!               wlv.char_attr = hl_combine_attr(wlv.line_attr, search_attr);
  # ifdef FEAT_SYN_HL
                wlv.char_attr = hl_combine_attr(syntax_attr, wlv.char_attr);
  # endif
            }
!           else if (wlv.line_attr != 0
                    && ((wlv.fromcol == -10 && wlv.tocol == MAXCOL)
                              || wlv.vcol < wlv.fromcol
                              || vcol_prev < fromcol_prev
                              || wlv.vcol >= wlv.tocol))
            {
!               // Use wlv.line_attr when not in the Visual or 'incsearch' area
                // (area_attr may be 0 when "noinvcur" is set).
  # ifdef FEAT_SYN_HL
!               wlv.char_attr = hl_combine_attr(syntax_attr, wlv.line_attr);
  # else
!               wlv.char_attr = wlv.line_attr;
  # endif
                attr_pri = FALSE;
            }
***************
*** 3051,3057 ****
  #  endif
  # endif
  # ifdef LINE_ATTR
!                           line_attr == 0
  # endif
                       )
  #endif
--- 3071,3077 ----
  #  endif
  # endif
  # ifdef LINE_ATTR
!                           wlv.line_attr == 0
  # endif
                       )
  #endif
***************
*** 3148,3154 ****
  # ifdef FEAT_TERMINAL
                            wlv.win_attr != 0 ||
  # endif
!                           line_attr != 0
                        ) && (
  # ifdef FEAT_RIGHTLEFT
                            wp->w_p_rl ? (wlv.col >= 0) :
--- 3168,3174 ----
  # ifdef FEAT_TERMINAL
                            wlv.win_attr != 0 ||
  # endif
!                           wlv.line_attr != 0
                        ) && (
  # ifdef FEAT_RIGHTLEFT
                            wp->w_p_rl ? (wlv.col >= 0) :
***************
*** 3167,3177 ****
                    ++did_line_attr;
  
                    // don't do search HL for the rest of the line
!                   if (line_attr != 0 && wlv.char_attr == search_attr
                                        && (did_line_attr > 1
                                            || (wp->w_p_list &&
                                                wp->w_lcs_chars.eol > 0)))
!                       wlv.char_attr = line_attr;
  # ifdef FEAT_DIFF
                    if (wlv.diff_hlf == HLF_TXD)
                    {
--- 3187,3197 ----
                    ++did_line_attr;
  
                    // don't do search HL for the rest of the line
!                   if (wlv.line_attr != 0 && wlv.char_attr == search_attr
                                        && (did_line_attr > 1
                                            || (wp->w_p_list &&
                                                wp->w_lcs_chars.eol > 0)))
!                       wlv.char_attr = wlv.line_attr;
  # ifdef FEAT_DIFF
                    if (wlv.diff_hlf == HLF_TXD)
                    {
***************
*** 3202,3210 ****
                                wlv.char_attr = hl_combine_attr(
                                              wlv.char_attr, HL_ATTR(HLF_CUL));
                        }
!                       else if (line_attr)
!                           wlv.char_attr = hl_combine_attr(wlv.char_attr,
!                                                                   line_attr);
                    }
  # endif
                }
--- 3222,3230 ----
                                wlv.char_attr = hl_combine_attr(
                                              wlv.char_attr, HL_ATTR(HLF_CUL));
                        }
!                       else if (wlv.line_attr)
!                           wlv.char_attr = hl_combine_attr(
!                                                wlv.char_attr, wlv.line_attr);
                    }
  # endif
                }
***************
*** 3325,3332 ****
                   ))
        {
  #ifdef LINE_ATTR
!           if (line_attr)
!               wlv.char_attr = hl_combine_attr(line_attr, wlv.extra_attr);
            else
  #endif
                wlv.char_attr = wlv.extra_attr;
--- 3345,3352 ----
                   ))
        {
  #ifdef LINE_ATTR
!           if (wlv.line_attr)
!               wlv.char_attr = hl_combine_attr(wlv.line_attr, wlv.extra_attr);
            else
  #endif
                wlv.char_attr = wlv.extra_attr;
*** ../vim-9.0.0981/src/testdir/test_textprop.vim       2022-11-29 
21:36:52.130387013 +0000
--- src/testdir/test_textprop.vim       2022-12-01 18:33:21.302880024 +0000
***************
*** 2918,2923 ****
--- 2918,2946 ----
    call StopVimInTerminal(buf)
  endfunc
  
+ func Test_prop_with_text_below_cul()
+   CheckRunVimInTerminal
+ 
+   let lines =<< trim END
+       vim9script
+ 
+       setline(1, ['some text', 'last line'])
+       set cursorline nowrap
+       prop_type_add('test', {highlight: 'DiffChange'})
+       prop_add(1, 0, {
+           type: 'test',
+           text: 'The quick brown fox jumps over the lazy dog',
+           text_align: 'below',
+           text_padding_left: 4,
+       })
+   END
+   call writefile(lines, 'XscriptPropsBelowCurline', 'D')
+   let buf = RunVimInTerminal('-S XscriptPropsBelowCurline', #{rows: 6, cols: 
60})
+   call VerifyScreenDump(buf, 'Test_prop_with_text_below_cul_1', {})
+ 
+   call StopVimInTerminal(buf)
+ endfunc
+ 
  func Test_props_with_text_below_nowrap()
    CheckRunVimInTerminal
  
*** ../vim-9.0.0981/src/testdir/dumps/Test_prop_with_text_below_cul_1.dump      
2022-12-01 18:36:59.446931072 +0000
--- src/testdir/dumps/Test_prop_with_text_below_cul_1.dump      2022-12-01 
18:33:38.638884562 +0000
***************
*** 0 ****
--- 1,6 ----
+ >s+8&#ffffff0|o|m|e| |t|e|x|t| @50
+ @4|T+8&#ffd7ff255|h|e| |q|u|i|c|k| |b|r|o|w|n| |f|o|x| |j|u|m|p|s| |o|v|e|r| 
|t|h|e| |l|a|z|y| |d|o|g| +8&#ffffff0@12
+ |l+0&&|a|s|t| |l|i|n|e| @50
+ |~+0#4040ff13&| @58
+ |~| @58
+ | +0#0000000&@41|1|,|1| @10|A|l@1| 
*** ../vim-9.0.0981/src/version.c       2022-12-01 12:29:39.976957379 +0000
--- src/version.c       2022-12-01 18:34:37.866899321 +0000
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     982,
  /**/

-- 
Some of the well known MS-Windows errors:
        EHUH            Unexpected error
        EUSER           User error, not our fault!
        EGOD            Horrible problem, god knows what has happened
        EERR            Errornous error: nothing wrong

 /// 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/20221201183849.1557E1C06AE%40moolenaar.net.

Raspunde prin e-mail lui