Skip to content

Commit 79f8b84

Browse files
committed
patch 9.0.0442: virtual text "above" doesn't handel line numbers
Problem: Virtual text "above" doesn't handel line numbers. Solution: Take the left column offset into account. (issue #11084) Also make padding work.
1 parent c069ede commit 79f8b84

File tree

7 files changed

+23
-7
lines changed

7 files changed

+23
-7
lines changed

src/drawline.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ text_prop_position(
350350
if (above)
351351
{
352352
before = 0;
353-
after = wp->w_width - cells;
353+
after = wp->w_width - cells - win_col_off(wp) - padding;
354354
}
355355
else
356356
{
@@ -436,6 +436,8 @@ text_prop_position(
436436
*p_extra = l;
437437
*n_extra = n_used + before + after + padding;
438438
*n_attr = mb_charlen(*p_extra);
439+
if (above)
440+
*n_attr -= padding;
439441
*n_attr_skip = before + padding + col_off;
440442
}
441443
}
@@ -1858,8 +1860,8 @@ win_line(
18581860
dont_use_showbreak = TRUE;
18591861
}
18601862
#endif
1861-
if ((right || above || below || !wrap || padding > 0)
1862-
&& wp->w_width > 2)
1863+
if ((right || above || below || !wrap
1864+
|| padding > 0) && wp->w_width > 2)
18631865
{
18641866
char_u *prev_p_extra = wlv.p_extra;
18651867
int start_line;

src/testdir/dumps/Test_prop_with_text_above_1.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
|s+0&#ffd7ff255|e|c|o|n|d| |t|h|i|n|g| |a|b|o|v|e| @41
33
|o+0&#ffffff0|n|e| |t|w|o| @52
44
|t|h|r>e@1| |f|o|u|r| @49
5-
|a+0&#ffff4012|n|o|t|h|e|r| |t|h|i|n|g| @46
5+
@3|a+0&#ffff4012|n|o|t|h|e|r| |t|h|i|n|g| @43
66
|f+0&#ffffff0|i|v|e| |s|i|x| @51
77
|~+0#4040ff13&| @58
88
|~| @58

src/testdir/dumps/Test_prop_with_text_above_2.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
|s+0&#ffd7ff255|e|c|o|n|d| |t|h|i|n|g| |a|b|o|v|e| @41
33
>o+0&#ffffff0|n|e| |t|w|o| @52
44
|t|h|r|e@1| |f|o|u|r| @49
5-
|a+0&#ffff4012|n|o|t|h|e|r| |t|h|i|n|g| @46
5+
@3|a+0&#ffff4012|n|o|t|h|e|r| |t|h|i|n|g| @43
66
|f+0&#ffffff0|i|v|e| |s|i|x| @51
77
|~+0#4040ff13&| @58
88
|~| @58

src/testdir/dumps/Test_prop_with_text_above_3.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
|s+0&#ffd7ff255|e|c|o|n|d| |t|h|i|n|g| |a|b|o|v|e| @41
33
|i+0&#ffffff0|n|s|e|r|t|e|d> |o|n|e| |t|w|o| @43
44
|t|h|r|e@1| |f|o|u|r| @49
5-
|a+0&#ffff4012|n|o|t|h|e|r| |t|h|i|n|g| @46
5+
@3|a+0&#ffff4012|n|o|t|h|e|r| |t|h|i|n|g| @43
66
|f+0&#ffffff0|i|v|e| |s|i|x| @51
77
|~+0#4040ff13&| @58
88
|~| @58
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&@41|1|,|9|-|1@1|7| @6|A|l@1|

src/testdir/test_textprop.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2857,7 +2857,7 @@ func Test_props_with_text_above()
28572857
call prop_type_add('above2', #{highlight: 'DiffChange'})
28582858
call prop_add(1, 0, #{type: 'above1', text: 'first thing above', text_align: 'above'})
28592859
call prop_add(1, 0, #{type: 'above2', text: 'second thing above', text_align: 'above'})
2860-
call prop_add(3, 0, #{type: 'above1', text: 'another thing', text_align: 'above'})
2860+
call prop_add(3, 0, #{type: 'above1', text: 'another thing', text_align: 'above', text_padding_left: 3})
28612861

28622862
normal gglllj
28632863
END
@@ -2870,6 +2870,9 @@ func Test_props_with_text_above()
28702870
call term_sendkeys(buf, "inserted \<Esc>")
28712871
call VerifyScreenDump(buf, 'Test_prop_with_text_above_3', {})
28722872

2873+
call term_sendkeys(buf, ":set number signcolumn=yes\<CR>")
2874+
call VerifyScreenDump(buf, 'Test_prop_with_text_above_4', {})
2875+
28732876
call StopVimInTerminal(buf)
28742877
endfunc
28752878

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+
442,
706708
/**/
707709
441,
708710
/**/

0 commit comments

Comments
 (0)