1
0
forked from aniani/vim

patch 9.0.0705: virtual text truncation does not take padding into account

Problem:    Virtual text truncation does not take padding into account.
Solution:   Subtract the padding from the available space. (closes #11318)
This commit is contained in:
Bram Moolenaar
2022-10-09 15:26:03 +01:00
parent b7af5a0445
commit 13845c48d8
4 changed files with 43 additions and 2 deletions

View File

@@ -573,6 +573,7 @@ textprop_size_after_trunc(
win_T *wp, win_T *wp,
int flags, // TP_FLAG_ALIGN_* int flags, // TP_FLAG_ALIGN_*
int added, int added,
int padding,
char_u *text, char_u *text,
int *n_used_ptr) int *n_used_ptr)
{ {
@@ -585,6 +586,8 @@ textprop_size_after_trunc(
// if the remaining size is to small wrap anyway and use the next line // if the remaining size is to small wrap anyway and use the next line
if (space < PROP_TEXT_MIN_CELLS) if (space < PROP_TEXT_MIN_CELLS)
space += wp->w_width; space += wp->w_width;
if (flags & TP_FLAG_ALIGN_BELOW)
space -= padding;
for (n_used = 0; n_used < len; n_used += (*mb_ptr2len)(text + n_used)) for (n_used = 0; n_used < len; n_used += (*mb_ptr2len)(text + n_used))
{ {
int clen = ptr2cells(text + n_used); int clen = ptr2cells(text + n_used);
@@ -629,7 +632,7 @@ text_prop_position(
char_u *l = NULL; char_u *l = NULL;
int strsize = vim_strsize(*p_extra); int strsize = vim_strsize(*p_extra);
int cells = wrap ? strsize : textprop_size_after_trunc(wp, int cells = wrap ? strsize : textprop_size_after_trunc(wp,
tp->tp_flags, before, *p_extra, &n_used); tp->tp_flags, before, padding, *p_extra, &n_used);
if (wrap || right || above || below || padding > 0 || n_used < *n_extra) if (wrap || right || above || below || padding > 0 || n_used < *n_extra)
{ {
@@ -715,7 +718,7 @@ text_prop_position(
// change last character to '…' // change last character to '…'
lp -= (*mb_head_off)(l, lp); lp -= (*mb_head_off)(l, lp);
STRCPY(lp, ""); STRCPY(lp, "");
n_used = lp - l + 3 - padding; n_used = lp - l + 3 - before - padding;
} }
else else
// change last character to '>' // change last character to '>'

View File

@@ -0,0 +1,8 @@
|f+0&#ffffff0|i|r|s|t| |l|i|n|e| @49
@3|a+0&#ffd7ff255|f|t|e|r| |a|f|t|e|r| |a|f|t|e|r| |a|f|t|e|r| |a|f|t|e|r| |a|f|t|e|r| |a|f|t|e|r| |a|f|t|e|r| |a|f|t|e|r| |a|f|…
| +0&#ffffff0@29|m+0&#ffd7ff255|o|r|e| |m|o|r|e| |m|o|r|e| |m|o|r|e| |m|o|r|e| |m|o|r|e|…
|s+0&#ffffff0|e|c|o|n|d| >l|i|n|e| @48
|~+0#4040ff13&| @58
|~| @58
|~| @58
| +0#0000000&@41|2|,|8| @10|A|l@1|

View File

@@ -3183,6 +3183,34 @@ func Test_insert_text_with_padding()
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
endfunc endfunc
func Test_long_text_below_with_padding()
CheckRunVimInTerminal
let lines =<< trim END
vim9script
setline(1, ['first line', 'second line'])
prop_type_add('theprop', {highlight: 'DiffChange'})
prop_add(1, 0, {
type: 'theprop',
text: 'after '->repeat(20),
text_align: 'below',
text_padding_left: 3,
})
prop_add(1, 0, {
type: 'theprop',
text: 'more '->repeat(20),
text_align: 'below',
text_padding_left: 30,
})
normal 2Gw
END
call writefile(lines, 'XlongTextBelowWithPadding', 'D')
let buf = RunVimInTerminal('-S XlongTextBelowWithPadding', #{rows: 8, cols: 60})
call VerifyScreenDump(buf, 'Test_long_text_with_padding_1', {})
call StopVimInTerminal(buf)
endfunc
func Test_insert_text_change_arg() func Test_insert_text_change_arg()
CheckRunVimInTerminal CheckRunVimInTerminal

View File

@@ -699,6 +699,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
705,
/**/ /**/
704, 704,
/**/ /**/