Patch 9.0.0451
Problem: Virtual text "above" does not work with 'nowrap'.
Solution: Do wrap the line after. (closes #11084)
Files: src/drawline.c, src/move.c, src/misc1.c, src/textprop.c,
src/proto/
textprop.pro, src/testdir/test_textprop.vim,
src/testdir/dumps/Test_prop_with_text_above_5.dump
*** ../vim-9.0.0450/src/drawline.c 2022-09-11 13:30:21.925587357 +0100
--- src/drawline.c 2022-09-12 17:45:20.095311681 +0100
***************
*** 666,671 ****
--- 666,672 ----
// syntax_attr
int text_prop_id = 0; // active property ID
int text_prop_flags = 0;
+ int text_prop_above = FALSE; // first doing virtual text above
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
***************
*** 1784,1789 ****
--- 1785,1791 ----
// Sort the properties on priority and/or starting last.
// Then combine the attributes, highest priority last.
+ text_prop_above = FALSE;
text_prop_follows = FALSE;
sort_text_props(wp->w_buffer, text_props,
text_prop_idxs, text_props_active);
***************
*** 1817,1822 ****
--- 1819,1826 ----
char_u *p = ((char_u **)wp->w_buffer
->b_textprop_text.ga_data)[
-text_prop_id - 1];
+ int above = (tp->tp_flags
+ & TP_FLAG_ALIGN_ABOVE);
// reset the ID in the copy to avoid it being used
// again
***************
*** 1826,1833 ****
{
int right = (tp->tp_flags
& TP_FLAG_ALIGN_RIGHT);
- int above = (tp->tp_flags
- & TP_FLAG_ALIGN_ABOVE);
int below = (tp->tp_flags
& TP_FLAG_ALIGN_BELOW);
int wrap = (tp->tp_flags & TP_FLAG_WRAP);
--- 1830,1835 ----
***************
*** 1902,1907 ****
--- 1904,1912 ----
// If another text prop follows the condition below at
// the last window column must know.
+ // If this is an "above" text prop and 'nowrap' the we
+ // must wrap anyway.
+ text_prop_above = above;
text_prop_follows = other_tpi != -1;
}
}
***************
*** 3581,3587 ****
|| filler_todo > 0
#endif
#ifdef FEAT_PROP_POPUP
! || text_prop_follows
#endif
|| (wp->w_p_list && wp->w_lcs_chars.eol != NUL
&& wlv.p_extra != at_end_str)
--- 3586,3592 ----
|| filler_todo > 0
#endif
#ifdef FEAT_PROP_POPUP
! || text_prop_above || text_prop_follows
#endif
|| (wp->w_p_list && wp->w_lcs_chars.eol != NUL
&& wlv.p_extra != at_end_str)
***************
*** 3608,3619 ****
&& filler_todo <= 0
#endif
#ifdef FEAT_PROP_POPUP
! && !text_prop_follows
#endif
) || lcs_eol_one == -1)
break;
#ifdef FEAT_PROP_POPUP
! if (!wp->w_p_wrap && text_prop_follows)
{
// do not output more of the line, only the "below" prop
ptr += STRLEN(ptr);
--- 3613,3624 ----
&& filler_todo <= 0
#endif
#ifdef FEAT_PROP_POPUP
! && !text_prop_above && !text_prop_follows
#endif
) || lcs_eol_one == -1)
break;
#ifdef FEAT_PROP_POPUP
! if (!wp->w_p_wrap && text_prop_follows && !text_prop_above)
{
// do not output more of the line, only the "below" prop
ptr += STRLEN(ptr);
***************
*** 3647,3653 ****
&& filler_todo <= 0
#endif
#ifdef FEAT_PROP_POPUP
! && !text_prop_follows
#endif
&& wp->w_width == Columns)
{
--- 3652,3658 ----
&& filler_todo <= 0
#endif
#ifdef FEAT_PROP_POPUP
! && !text_prop_above && !text_prop_follows
#endif
&& wp->w_width == Columns)
{
*** ../vim-9.0.0450/src/move.c 2022-09-11 16:59:48.934110049 +0100
--- src/move.c 2022-09-12 16:40:10.086927214 +0100
***************
*** 1068,1073 ****
--- 1068,1086 ----
#endif
)
{
+ #ifdef FEAT_PROP_POPUP
+ if (curwin->w_virtcol_first_char > 0)
+ {
+ int cols = (curwin->w_width - extra);
+ int rows = cols > 0 ? curwin->w_virtcol_first_char / cols : 1;
+
+ // each "above" text prop shifts the text one row down
+ curwin->w_wrow += rows;
+ curwin->w_wcol -= rows * cols;
+ endcol -= rows * cols;
+ curwin->w_cline_height = rows + 1;
+ }
+ #endif
/*
* If Cursor is left of the screen, scroll rightwards.
* If Cursor is right of the screen, scroll leftwards
*** ../vim-9.0.0450/src/misc1.c 2022-08-29 15:06:46.720715534 +0100
--- src/misc1.c 2022-09-12 16:48:05.065564868 +0100
***************
*** 377,384 ****
if (!wp->w_p_wrap)
lines = 1
#ifdef FEAT_PROP_POPUP
! // add a line for each "below" aligned text property
! + prop_count_below(wp->w_buffer, lnum)
#endif
;
else
--- 377,384 ----
if (!wp->w_p_wrap)
lines = 1
#ifdef FEAT_PROP_POPUP
! // add a line for each "above" and "below" aligned text property
! + prop_count_above_below(wp->w_buffer, lnum)
#endif
;
else
*** ../vim-9.0.0450/src/textprop.c 2022-09-10 20:00:31.117468669 +0100
--- src/textprop.c 2022-09-12 16:47:36.489658828 +0100
***************
*** 608,619 ****
}
/*
! * Return the number of text properties with "below" alignment in line "lnum".
! * A "right" aligned property also goes below after a "below" or other "right"
! * aligned property.
*/
int
! prop_count_below(buf_T *buf, linenr_T lnum)
{
char_u *props;
int count = get_text_props(buf, lnum, &props, FALSE);
--- 608,619 ----
}
/*
! * Return the number of text properties with "above" or "below" alignment in
! * line "lnum". A "right" aligned property also goes below after a "below" or
! * other "right" aligned property.
*/
int
! prop_count_above_below(buf_T *buf, linenr_T lnum)
{
char_u *props;
int count = get_text_props(buf, lnum, &props, FALSE);
***************
*** 636,641 ****
--- 636,646 ----
next_right_goes_below = TRUE;
++result;
}
+ else if (prop.tp_flags & TP_FLAG_ALIGN_ABOVE)
+ {
+ next_right_goes_below = FALSE;
+ ++result;
+ }
else if (prop.tp_flags & TP_FLAG_ALIGN_RIGHT)
next_right_goes_below = TRUE;
}
*** ../vim-9.0.0450/src/proto/
textprop.pro 2022-08-23 18:39:14.756797669 +0100
--- src/proto/
textprop.pro 2022-09-12 16:48:04.109567997 +0100
***************
*** 4,10 ****
void f_prop_add_list(typval_T *argvars, typval_T *rettv);
int prop_add_common(linenr_T start_lnum, colnr_T start_col, dict_T *dict, buf_T *default_buf, typval_T *dict_arg);
int get_text_props(buf_T *buf, linenr_T lnum, char_u **props, int will_change);
! int prop_count_below(buf_T *buf, linenr_T lnum);
int count_props(linenr_T lnum, int only_starting, int last_line);
void sort_text_props(buf_T *buf, textprop_T *props, int *idxs, int count);
int find_visible_prop(win_T *wp, int type_id, int id, textprop_T *prop, linenr_T *found_lnum);
--- 4,10 ----
void f_prop_add_list(typval_T *argvars, typval_T *rettv);
int prop_add_common(linenr_T start_lnum, colnr_T start_col, dict_T *dict, buf_T *default_buf, typval_T *dict_arg);
int get_text_props(buf_T *buf, linenr_T lnum, char_u **props, int will_change);
! int prop_count_above_below(buf_T *buf, linenr_T lnum);
int count_props(linenr_T lnum, int only_starting, int last_line);
void sort_text_props(buf_T *buf, textprop_T *props, int *idxs, int count);
int find_visible_prop(win_T *wp, int type_id, int id, textprop_T *prop, linenr_T *found_lnum);
*** ../vim-9.0.0450/src/testdir/test_textprop.vim 2022-09-11 13:30:21.925587357 +0100
--- src/testdir/test_textprop.vim 2022-09-12 17:47:25.654947586 +0100
***************
*** 2873,2878 ****
--- 2873,2881 ----
call term_sendkeys(buf, ":set number signcolumn=yes\<CR>")
call VerifyScreenDump(buf, 'Test_prop_with_text_above_4', {})
+ call term_sendkeys(buf, ":set nowrap\<CR>gg$j")
+ call VerifyScreenDump(buf, 'Test_prop_with_text_above_5', {})
+
call StopVimInTerminal(buf)
endfunc
*** ../vim-9.0.0450/src/testdir/dumps/Test_prop_with_text_above_5.dump 2022-09-12 17:49:23.142607974 +0100
--- src/testdir/dumps/Test_prop_with_text_above_5.dump 2022-09-12 17:47:36.382916535 +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&|n|s|e|r|t|e|d| |o|n|e| |t|w|o| @37
+ | +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
+ |~| @58
+ |:+0#0000000&|s|e|t| |n|o|w|r|a|p| @30|2|,|1|0| @9|A|l@1|
*** ../vim-9.0.0450/src/version.c 2022-09-12 14:09:26.550006991 +0100
--- src/version.c 2022-09-12 15:15:01.104217748 +0100
***************
*** 705,706 ****
--- 705,708 ----
{ /* Add new patch number below this line */
+ /**/
+ 451,
/**/
--
hundred-and-one symptoms of being an internet addict:
50. The last girl you picked up was only a jpeg.
/// Bram Moolenaar -- Br...@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 ///