patch 9.0.0721: virtual text "above" with padding not displayed correctly

Problem:    Virtual text "above" with padding not displayed correctly.
Solution:   Take padding into account when truncating. (closes #11340)
This commit is contained in:
Bram Moolenaar
2022-10-11 14:54:42 +01:00
parent 0c502d2e70
commit 9466fb8001
4 changed files with 21 additions and 2 deletions

View File

@ -459,7 +459,7 @@ handle_lnum_col(
handle_breakindent(win_T *wp, winlinevars_T *wlv)
{
if (wp->w_briopt_sbr && wlv->draw_state == WL_BRI - 1
&& *get_showbreak_value(wp) != NUL)
&& *get_showbreak_value(wp) != NUL)
// draw indent after showbreak value
wlv->draw_state = WL_BRI;
else if (wp->w_briopt_sbr && wlv->draw_state == WL_SBR)
@ -586,7 +586,7 @@ textprop_size_after_trunc(
// if the remaining size is to small wrap anyway and use the next line
if (space < PROP_TEXT_MIN_CELLS)
space += wp->w_width;
if (flags & TP_FLAG_ALIGN_BELOW)
if (flags & (TP_FLAG_ALIGN_BELOW | TP_FLAG_ALIGN_ABOVE))
space -= padding;
for (n_used = 0; n_used < len; n_used += (*mb_ptr2len)(text + n_used))
{

View File

@ -0,0 +1,9 @@
| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@3|f+0#0000000#ffff4012|i|r|s|t| |t|h|i|n|g| |a|b|o|v|e| +0&#ffffff0@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| +0&#ffffff0@35
| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@3| +0#0000000&@1|0+0&#ffff4012| |1| |2| |3| |4| |5| |6| |7| |8| |9| |1|0| |1@1| |1|2| |1|3| |1|4| |1|5| |1|6| |1|7| |1|8| |1|9| |2|…
| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@1|1| |i+0#0000000&|n|s|e|r|t|e|d| @45
| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@1|2| >o+0#0000000&|n|e| |t|w|o| @46
| +0#0000e05#a8a8a8255@1| +0#af5f00255#ffffff0@3|b+0#0000000#5fd7ff255|e|l|o|w| +0&#ffffff0@48
|~+0#4040ff13&| @58
|~| @58
|:+0#0000000&|c|a|l@1| |A|d@1|L|o|n|g|P|r|o|p|A|b|o|v|e|(|)| @17|2|,|1| @10|A|l@1|

View File

@ -2852,6 +2852,11 @@ func Test_props_with_text_above()
func AddPropBelow()
call prop_add(1, 0, #{type: 'below', text: 'below', text_align: 'below'})
endfunc
func AddLongPropAbove()
3,4delete
set wrap
call prop_add(1, 0, #{type: 'above1', text: range(50)->join(' '), text_align: 'above', text_padding_left: 2})
endfunc
END
call writefile(lines, 'XscriptPropsWithTextAbove', 'D')
let buf = RunVimInTerminal('-S XscriptPropsWithTextAbove', #{rows: 9, cols: 60})
@ -2887,6 +2892,9 @@ func Test_props_with_text_above()
call term_sendkeys(buf, "\<Esc>ls\<CR>\<Esc>")
call VerifyScreenDump(buf, 'Test_prop_with_text_above_8', {})
call term_sendkeys(buf, ":call AddLongPropAbove()\<CR>")
call VerifyScreenDump(buf, 'Test_prop_with_text_above_9', {})
call StopVimInTerminal(buf)
endfunc

View File

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