diff --git a/src/charset.c b/src/charset.c index 9c68d4af75..5ea329fae3 100644 --- a/src/charset.c +++ b/src/charset.c @@ -1281,6 +1281,9 @@ win_lbr_chartabsize( # ifdef FEAT_PROP_POPUP if (cts->cts_has_prop_with_text) { + if (*s == TAB) + size = wp->w_buffer->b_p_ts; + int tab_size = size; int charlen = *s == NUL ? 1 : mb_ptr2len(s); int i; diff --git a/src/drawline.c b/src/drawline.c index 2388193b97..fa5a1ccd0c 100644 --- a/src/drawline.c +++ b/src/drawline.c @@ -3229,13 +3229,21 @@ win_line( { int tab_len = 0; long vcol_adjusted = wlv.vcol; // removed showbreak len +#ifdef FEAT_PROP_POPUP + // the lenght of above virtual text may add up to a number + // that is not a multiple of 'ts', adjust here to fix the + // calculation of tab_len + if (wlv.text_prop_above_count > 0) + vcol_adjusted -= (wp->w_width - win_col_off(wp)) + * wlv.text_prop_above_count % wp->w_buffer->b_p_ts; +#endif #ifdef FEAT_LINEBREAK char_u *sbr = get_showbreak_value(wp); // only adjust the tab_len, when at the first column // after the showbreak value was drawn - if (*sbr != NUL && wlv.vcol == wlv.vcol_sbr && wp->w_p_wrap) - vcol_adjusted = wlv.vcol - MB_CHARLEN(sbr); + if (*sbr != NUL && vcol_adjusted == wlv.vcol_sbr && wp->w_p_wrap) + vcol_adjusted -= MB_CHARLEN(sbr); #endif // tab amount depends on current column #ifdef FEAT_VARTABS diff --git a/src/testdir/dumps/Test_prop_above_tablen_1.dump b/src/testdir/dumps/Test_prop_above_tablen_1.dump new file mode 100644 index 0000000000..8b47c217e9 --- /dev/null +++ b/src/testdir/dumps/Test_prop_above_tablen_1.dump @@ -0,0 +1,11 @@ +| +0&#ffffff0@15|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@10 +@16|a+0#4040ff13&|b|o|v|e| |2| +0#0000000&@10 +|<+0#0000e05&|-@5|>|<|-@5|>>o+0#0000000&|n|e| @14 +@8|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@18 +|<+0#0000e05&|-@5|>|t+0#0000000&|w|o| @22 +@8|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@18 +@3|<+0#0000e05&|-@2|>|3+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e| |t|h|r|e@1|<+0#0000e05&|-@3|>|*+0#0000000&|<+0#0000e05& +|-@4|>|l+0#0000000&|i|n|e|<+0#0000e05&|-@1|>|t+0#0000000&|h|r|e@1| @14 +@3|<+0#0000e05&|-@2|>|3+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e| |t|h|r|e@1|<+0#0000e05&|-@3|>|*+0#0000000&|<+0#0000e05& +|-@4|>|l+0#0000000&|i|n|e|<+0#0000e05&|-@1|>|t+0#0000000&|h|r|e@1| @14 +@17|1|,|3|-|8|5| @6|A|l@1| diff --git a/src/testdir/dumps/Test_prop_above_tablen_2.dump b/src/testdir/dumps/Test_prop_above_tablen_2.dump new file mode 100644 index 0000000000..1ffc3d50f4 --- /dev/null +++ b/src/testdir/dumps/Test_prop_above_tablen_2.dump @@ -0,0 +1,11 @@ +| +0&#ffffff0@15|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@9 +@16|a+0#4040ff13&|b|o|v|e| |2| +0#0000000&@9 +|<+0#0000e05&|-@5|>|<|-@5|>>o+0#0000000&|n|e| @13 +@8|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@17 +|<+0#0000e05&|-@5|>|t+0#0000000&|w|o| @21 +@8|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@17 +@3|<+0#0000e05&|-@2|>|3+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e| |t|h|r|e@1|<+0#0000e05&|-@3|>|*+0#0000000& +|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e|<+0#0000e05&|-@1|>|t+0#0000000&|h|r|e@1| @12 +@3|<+0#0000e05&|-@2|>|3+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e| |t|h|r|e@1|<+0#0000e05&|-@3|>|*+0#0000000& +|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e|<+0#0000e05&|-@1|>|t+0#0000000&|h|r|e@1| @12 +@17|1|,|3|-|8|3| @5|A|l@1| diff --git a/src/testdir/dumps/Test_prop_above_tablen_3.dump b/src/testdir/dumps/Test_prop_above_tablen_3.dump new file mode 100644 index 0000000000..5d9aa1a294 --- /dev/null +++ b/src/testdir/dumps/Test_prop_above_tablen_3.dump @@ -0,0 +1,11 @@ +| +0&#ffffff0@15|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@8 +@16|a+0#4040ff13&|b|o|v|e| |2| +0#0000000&@8 +|<+0#0000e05&|-@5|>|<|-@5|>>o+0#0000000&|n|e| @12 +@8|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@16 +|<+0#0000e05&|-@5|>|t+0#0000000&|w|o| @20 +@8|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@16 +@3|<+0#0000e05&|-@2|>|3+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e| |t|h|r|e@1|<+0#0000e05&|-@3|> +|*+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e|<+0#0000e05&|-@1|>|t+0#0000000&|h|r|e@1| @10 +@3|<+0#0000e05&|-@2|>|3+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e| |t|h|r|e@1|<+0#0000e05&|-@3|> +|*+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e|<+0#0000e05&|-@1|>|t+0#0000000&|h|r|e@1| @10 +@16|1|,|3|-|8|1| @5|A|l@1| diff --git a/src/testdir/dumps/Test_prop_above_tablen_4.dump b/src/testdir/dumps/Test_prop_above_tablen_4.dump new file mode 100644 index 0000000000..10e9e73c99 --- /dev/null +++ b/src/testdir/dumps/Test_prop_above_tablen_4.dump @@ -0,0 +1,11 @@ +| +0&#ffffff0@15|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@7 +@16|a+0#4040ff13&|b|o|v|e| |2| +0#0000000&@7 +|<+0#0000e05&|-@5|>|<|-@5|>>o+0#0000000&|n|e| @11 +@8|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@15 +|<+0#0000e05&|-@5|>|t+0#0000000&|w|o| @19 +@8|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@15 +@3|<+0#0000e05&|-@2|>|3+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e| |t|h|r|e@1|<+0#0000e05&|-@3 +|>|*+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e|<+0#0000e05&|-@1|>|t+0#0000000&|h|r|e@1| @8 +@3|<+0#0000e05&|-@2|>|3+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e| |t|h|r|e@1|<+0#0000e05&|-@3 +|>|*+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e|<+0#0000e05&|-@1|>|t+0#0000000&|h|r|e@1| @8 +@16|1|,|3|-|7|9| @4|A|l@1| diff --git a/src/testdir/dumps/Test_prop_above_tablen_5.dump b/src/testdir/dumps/Test_prop_above_tablen_5.dump new file mode 100644 index 0000000000..1c4a771aa1 --- /dev/null +++ b/src/testdir/dumps/Test_prop_above_tablen_5.dump @@ -0,0 +1,11 @@ +| +0&#ffffff0@15|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@6 +@16|a+0#4040ff13&|b|o|v|e| |2| +0#0000000&@6 +|<+0#0000e05&|-@5|>|<|-@5|>>o+0#0000000&|n|e| @10 +@8|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@14 +|<+0#0000e05&|-@5|>|t+0#0000000&|w|o| @18 +@8|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@14 +@3|<+0#0000e05&|-@2|>|3+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e| |t|h|r|e@1|<+0#0000e05&|-@2 +@1|>|*+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e|<+0#0000e05&|-@1|>|t+0#0000000&|h|r|e@1| @6 +@3|<+0#0000e05&|-@2|>|3+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e| |t|h|r|e@1|<+0#0000e05&|-@2 +@1|>|*+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e|<+0#0000e05&|-@1|>|t+0#0000000&|h|r|e@1| @6 +@15|1|,|3|-|7@1| @4|A|l@1| diff --git a/src/testdir/dumps/Test_prop_above_tablen_6.dump b/src/testdir/dumps/Test_prop_above_tablen_6.dump new file mode 100644 index 0000000000..2927a4ba55 --- /dev/null +++ b/src/testdir/dumps/Test_prop_above_tablen_6.dump @@ -0,0 +1,11 @@ +| +0&#ffffff0@15|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@5 +@16|a+0#4040ff13&|b|o|v|e| |2| +0#0000000&@5 +|<+0#0000e05&|-@5|>|<|-@5|>>o+0#0000000&|n|e| @9 +@8|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@13 +|<+0#0000e05&|-@5|>|t+0#0000000&|w|o| @17 +@8|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@13 +@3|<+0#0000e05&|-@2|>|3+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e| |t|h|r|e@1|<+0#0000e05&|-@1 +@2|>|*+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e|<+0#0000e05&|-@1|>|t+0#0000000&|h|r|e@1| @4 +@3|<+0#0000e05&|-@2|>|3+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e| |t|h|r|e@1|<+0#0000e05&|-@1 +@2|>|*+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e|<+0#0000e05&|-@1|>|t+0#0000000&|h|r|e@1| @4 +@15|1|,|3|-|7|5| @3|A|l@1| diff --git a/src/testdir/dumps/Test_prop_above_tablen_7.dump b/src/testdir/dumps/Test_prop_above_tablen_7.dump new file mode 100644 index 0000000000..acc1246626 --- /dev/null +++ b/src/testdir/dumps/Test_prop_above_tablen_7.dump @@ -0,0 +1,11 @@ +| +0&#ffffff0@15|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@4 +@16|a+0#4040ff13&|b|o|v|e| |2| +0#0000000&@4 +|<+0#0000e05&|-@5|>|<|-@5|>>o+0#0000000&|n|e| @8 +@8|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@12 +|<+0#0000e05&|-@5|>|t+0#0000000&|w|o| @16 +@8|a+0#4040ff13&|b|o|v|e| |1| +0#0000000&@12 +@3|<+0#0000e05&|-@2|>|3+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e| |t|h|r|e@1|<+0#0000e05&|- +@3|>|*+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e|<+0#0000e05&|-@1|>|t+0#0000000&|h|r|e@1| @2 +@3|<+0#0000e05&|-@2|>|3+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e| |t|h|r|e@1|<+0#0000e05&|- +@3|>|*+0#0000000&|<+0#0000e05&|-@4|>|l+0#0000000&|i|n|e|<+0#0000e05&|-@1|>|t+0#0000000&|h|r|e@1| @2 +@14|1|,|3|-|7|3| @3|A|l@1| diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim index bcf83cab8f..d3a365dbe4 100644 --- a/src/testdir/test_textprop.vim +++ b/src/testdir/test_textprop.vim @@ -3732,6 +3732,38 @@ func Test_prop_above_with_indent() call prop_type_delete('indented') endfunc +func Test_prop_above_tablen() + CheckRunVimInTerminal + + let lines =<< trim END + vim9script + [ + "\t\tone", + "\ttwo", + " \t3\tline three\t*\tline\tthree", + " \t3\tline three\t*\tline\tthree", + ]->setline(1) + prop_type_add('above', {highlight: 'NonText'}) + prop_add(1, 0, { text: 'above 1', type: 'above', text_align: 'above', text_padding_left: 16, }) + prop_add(1, 0, { text: 'above 2', type: 'above', text_align: 'above', text_padding_left: 16, }) + prop_add(2, 0, { text: 'above 1', type: 'above', text_align: 'above', text_padding_left: 8, }) + prop_add(3, 0, { text: 'above 1', type: 'above', text_align: 'above', text_padding_left: 8, }) + set list listchars=tab:<-> + END + call writefile(lines, 'XscriptPropAboveTab', 'D') + let buf = RunVimInTerminal('-S XscriptPropAboveTab', #{cols: 34, rows: 11}) + call term_sendkeys(buf, "w") + call VerifyScreenDump(buf, 'Test_prop_above_tablen_1', {}) + + "TODO: also test for cursor position + for width in range(33, 28, -1) + call term_sendkeys(buf, ":set columns="..width.."\") + call VerifyScreenDump(buf, 'Test_prop_above_tablen_'..(35-width), {}) + endfor + + call StopVimInTerminal(buf) +endfunc + func Test_prop_above_with_number() CheckScreendump CheckRunVimInTerminal