Skip to content

Commit c9dc03f

Browse files
committed
patch 9.0.0451: virtual text "above" does not work with 'nowrap'
Problem: Virtual text "above" does not work with 'nowrap'. Solution: Do wrap the line after. (closes #11084)
1 parent 7b2d872 commit c9dc03f

8 files changed

Lines changed: 50 additions & 13 deletions

File tree

src/drawline.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ win_line(
666666
// syntax_attr
667667
int text_prop_id = 0; // active property ID
668668
int text_prop_flags = 0;
669+
int text_prop_above = FALSE; // first doing virtual text above
669670
int text_prop_follows = FALSE; // another text prop to display
670671
int saved_search_attr = 0; // search_attr to be used when n_extra
671672
// goes to zero
@@ -1784,6 +1785,7 @@ win_line(
17841785

17851786
// Sort the properties on priority and/or starting last.
17861787
// Then combine the attributes, highest priority last.
1788+
text_prop_above = FALSE;
17871789
text_prop_follows = FALSE;
17881790
sort_text_props(wp->w_buffer, text_props,
17891791
text_prop_idxs, text_props_active);
@@ -1817,6 +1819,8 @@ win_line(
18171819
char_u *p = ((char_u **)wp->w_buffer
18181820
->b_textprop_text.ga_data)[
18191821
-text_prop_id - 1];
1822+
int above = (tp->tp_flags
1823+
& TP_FLAG_ALIGN_ABOVE);
18201824

18211825
// reset the ID in the copy to avoid it being used
18221826
// again
@@ -1826,8 +1830,6 @@ win_line(
18261830
{
18271831
int right = (tp->tp_flags
18281832
& TP_FLAG_ALIGN_RIGHT);
1829-
int above = (tp->tp_flags
1830-
& TP_FLAG_ALIGN_ABOVE);
18311833
int below = (tp->tp_flags
18321834
& TP_FLAG_ALIGN_BELOW);
18331835
int wrap = (tp->tp_flags & TP_FLAG_WRAP);
@@ -1902,6 +1904,9 @@ win_line(
19021904

19031905
// If another text prop follows the condition below at
19041906
// the last window column must know.
1907+
// If this is an "above" text prop and 'nowrap' the we
1908+
// must wrap anyway.
1909+
text_prop_above = above;
19051910
text_prop_follows = other_tpi != -1;
19061911
}
19071912
}
@@ -3581,7 +3586,7 @@ win_line(
35813586
|| filler_todo > 0
35823587
#endif
35833588
#ifdef FEAT_PROP_POPUP
3584-
|| text_prop_follows
3589+
|| text_prop_above || text_prop_follows
35853590
#endif
35863591
|| (wp->w_p_list && wp->w_lcs_chars.eol != NUL
35873592
&& wlv.p_extra != at_end_str)
@@ -3608,12 +3613,12 @@ win_line(
36083613
&& filler_todo <= 0
36093614
#endif
36103615
#ifdef FEAT_PROP_POPUP
3611-
&& !text_prop_follows
3616+
&& !text_prop_above && !text_prop_follows
36123617
#endif
36133618
) || lcs_eol_one == -1)
36143619
break;
36153620
#ifdef FEAT_PROP_POPUP
3616-
if (!wp->w_p_wrap && text_prop_follows)
3621+
if (!wp->w_p_wrap && text_prop_follows && !text_prop_above)
36173622
{
36183623
// do not output more of the line, only the "below" prop
36193624
ptr += STRLEN(ptr);
@@ -3647,7 +3652,7 @@ win_line(
36473652
&& filler_todo <= 0
36483653
#endif
36493654
#ifdef FEAT_PROP_POPUP
3650-
&& !text_prop_follows
3655+
&& !text_prop_above && !text_prop_follows
36513656
#endif
36523657
&& wp->w_width == Columns)
36533658
{

src/misc1.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ plines_win_nofill(
377377
if (!wp->w_p_wrap)
378378
lines = 1
379379
#ifdef FEAT_PROP_POPUP
380-
// add a line for each "below" aligned text property
381-
+ prop_count_below(wp->w_buffer, lnum)
380+
// add a line for each "above" and "below" aligned text property
381+
+ prop_count_above_below(wp->w_buffer, lnum)
382382
#endif
383383
;
384384
else

src/move.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,19 @@ curs_columns(
10681068
#endif
10691069
)
10701070
{
1071+
#ifdef FEAT_PROP_POPUP
1072+
if (curwin->w_virtcol_first_char > 0)
1073+
{
1074+
int cols = (curwin->w_width - extra);
1075+
int rows = cols > 0 ? curwin->w_virtcol_first_char / cols : 1;
1076+
1077+
// each "above" text prop shifts the text one row down
1078+
curwin->w_wrow += rows;
1079+
curwin->w_wcol -= rows * cols;
1080+
endcol -= rows * cols;
1081+
curwin->w_cline_height = rows + 1;
1082+
}
1083+
#endif
10711084
/*
10721085
* If Cursor is left of the screen, scroll rightwards.
10731086
* If Cursor is right of the screen, scroll leftwards

src/proto/textprop.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ void f_prop_add(typval_T *argvars, typval_T *rettv);
44
void f_prop_add_list(typval_T *argvars, typval_T *rettv);
55
int prop_add_common(linenr_T start_lnum, colnr_T start_col, dict_T *dict, buf_T *default_buf, typval_T *dict_arg);
66
int get_text_props(buf_T *buf, linenr_T lnum, char_u **props, int will_change);
7-
int prop_count_below(buf_T *buf, linenr_T lnum);
7+
int prop_count_above_below(buf_T *buf, linenr_T lnum);
88
int count_props(linenr_T lnum, int only_starting, int last_line);
99
void sort_text_props(buf_T *buf, textprop_T *props, int *idxs, int count);
1010
int find_visible_prop(win_T *wp, int type_id, int id, textprop_T *prop, linenr_T *found_lnum);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
| +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
2+
| +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
3+
| +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
4+
| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@1|2| |t+0#0000000&|h|r|e@1| |f|o|u>r| @43
5+
| +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
6+
| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@3|f+0#0000000&|i|v|e| |s|i|x| @45
7+
|~+0#4040ff13&| @58
8+
|~| @58
9+
|:+0#0000000&|s|e|t| |n|o|w|r|a|p| @30|2|,|1|0| @9|A|l@1|

src/testdir/test_textprop.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2873,6 +2873,9 @@ func Test_props_with_text_above()
28732873
call term_sendkeys(buf, ":set number signcolumn=yes\<CR>")
28742874
call VerifyScreenDump(buf, 'Test_prop_with_text_above_4', {})
28752875

2876+
call term_sendkeys(buf, ":set nowrap\<CR>gg$j")
2877+
call VerifyScreenDump(buf, 'Test_prop_with_text_above_5', {})
2878+
28762879
call StopVimInTerminal(buf)
28772880
endfunc
28782881

src/textprop.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,12 +608,12 @@ get_text_props(buf_T *buf, linenr_T lnum, char_u **props, int will_change)
608608
}
609609

610610
/*
611-
* Return the number of text properties with "below" alignment in line "lnum".
612-
* A "right" aligned property also goes below after a "below" or other "right"
613-
* aligned property.
611+
* Return the number of text properties with "above" or "below" alignment in
612+
* line "lnum". A "right" aligned property also goes below after a "below" or
613+
* other "right" aligned property.
614614
*/
615615
int
616-
prop_count_below(buf_T *buf, linenr_T lnum)
616+
prop_count_above_below(buf_T *buf, linenr_T lnum)
617617
{
618618
char_u *props;
619619
int count = get_text_props(buf, lnum, &props, FALSE);
@@ -636,6 +636,11 @@ prop_count_below(buf_T *buf, linenr_T lnum)
636636
next_right_goes_below = TRUE;
637637
++result;
638638
}
639+
else if (prop.tp_flags & TP_FLAG_ALIGN_ABOVE)
640+
{
641+
next_right_goes_below = FALSE;
642+
++result;
643+
}
639644
else if (prop.tp_flags & TP_FLAG_ALIGN_RIGHT)
640645
next_right_goes_below = TRUE;
641646
}

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,8 @@ static char *(features[]) =
703703

704704
static int included_patches[] =
705705
{ /* Add new patch number below this line */
706+
/**/
707+
451,
706708
/**/
707709
450,
708710
/**/

0 commit comments

Comments
 (0)