Skip to content

Commit 51c3131

Browse files
committed
patch 8.1.1550: when a popup has left padding text may be cut off
Problem: When a popup has left padding text may be cut off. Solution: Add the border and padding when computing the size.
1 parent 61eeeea commit 51c3131

5 files changed

Lines changed: 18 additions & 13 deletions

File tree

src/popupwin.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ popup_adjust_position(win_T *wp)
588588
// When centering or right aligned, use maximum width.
589589
// When left aligned use the space available, but shift to the left when we
590590
// hit the right of the screen.
591-
maxwidth = Columns - wp->w_wincol;
591+
maxwidth = Columns - wp->w_wincol - left_extra;
592592
if (wp->w_maxwidth > 0 && maxwidth > wp->w_maxwidth)
593593
{
594594
allow_adjust_left = FALSE;
@@ -622,11 +622,12 @@ popup_adjust_position(win_T *wp)
622622
|| wp->w_popup_pos == POPPOS_BOTLEFT))
623623
{
624624
// adjust leftwise to fit text on screen
625-
int shift_by = ( len - maxwidth );
625+
int shift_by = len - maxwidth;
626626

627-
if ( shift_by > wp->w_wincol )
627+
if (shift_by > wp->w_wincol)
628628
{
629629
int truncate_shift = shift_by - wp->w_wincol;
630+
630631
len -= truncate_shift;
631632
shift_by -= truncate_shift;
632633
}

src/testdir/dumps/Test_popupwin_20.dump

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
|5| @40||+0#0000001#ffd7ff255| @11||| +0#0000000#ffffff0@18
66
|6| |++0#0000001#ffd7ff255|-@8| +0#0000000#ffffff0@9| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@4|++0#0000001#ffd7ff255|-@11|+| +0#0000000#ffffff0@18
77
|7| ||+0#0000001#ffd7ff255|b|o|r|d|e|r| |T|L| +0#0000000#ffffff0@9| +0#0000001#ffd7ff255@3|p|a|d@1|i|n|g|s| @2| +0#0000000#ffffff0@37
8-
|8| @20| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@37
9-
|9| @20| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@37
10-
|1|0| @72
11-
|1@1| @72
12-
|1|2| @72
8+
|8| @20| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@16||+0#0000001#ffd7ff255| @2|w|r|a|p@1|e|d| |l|o|n|g|e|r| |t|e
9+
|9+0#0000000#ffffff0| @20| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@16||+0#0000001#ffd7ff255| @2|x|t| @14
10+
|1+0#0000000#ffffff0|0| @72
11+
|1@1| @50||+0#0000001#ffd7ff255| @2|r|i|g|h|t| |a|l|i|g|n|e|d| |t|e|x|t
12+
|1+0#0000000#ffffff0|2| @72
1313
|1|3| @72
1414
|1|4| @72
1515
@57|1|,|1| @10|T|o|p|

src/testdir/dumps/Test_popupwin_21.dump

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
|5| @40|║+0#0000001#ffd7ff255| @11|║| +0#0000000#ffffff0@18
66
|6| |╔+0#0000001#ffd7ff255|═@8| +0#0000000#ffffff0@9| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@4|╚+0#0000001#ffd7ff255|═@11|╝| +0#0000000#ffffff0@18
77
|7| |║+0#0000001#ffd7ff255|b|o|r|d|e|r| |T|L| +0#0000000#ffffff0@9| +0#0000001#ffd7ff255@3|p|a|d@1|i|n|g|s| @2| +0#0000000#ffffff0@37
8-
|8| @20| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@37
9-
|9| @20| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@37
10-
|1|0| @72
11-
|1@1| @72
12-
|1|2| @72
8+
|8| @20| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@16|║+0#0000001#ffd7ff255| @2|w|r|a|p@1|e|d| |l|o|n|g|e|r| |t|e
9+
|9+0#0000000#ffffff0| @20| +0#0000001#ffd7ff255@14| +0#0000000#ffffff0@16|║+0#0000001#ffd7ff255| @2|x|t| @14
10+
|1+0#0000000#ffffff0|0| @72
11+
|1@1| @50|║+0#0000001#ffd7ff255| @2|r|i|g|h|t| |a|l|i|g|n|e|d| |t|e|x|t
12+
|1+0#0000000#ffffff0|2| @72
1313
|1|3| @72
1414
|1|4| @72
1515
@57|1|,|1| @10|T|o|p|

src/testdir/test_popupwin.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ func Test_popup_with_border_and_padding()
8787
\ "call popup_create('hello both', {'line': 2, 'col': 43, 'border': [], 'padding': []})",
8888
\ "call popup_create('border TL', {'line': 6, 'col': 3, 'border': [1, 0, 0, 4]})",
8989
\ "call popup_create('paddings', {'line': 6, 'col': 23, 'padding': [1, 3, 2, 4]})",
90+
\ "call popup_create('wrapped longer text', {'line': 8, 'col': 55, 'padding': [0, 3, 0, 3], 'border': [0, 1, 0, 1]})",
91+
\ "call popup_create('right aligned text', {'line': 11, 'col': 56, 'wrap': 0, 'padding': [0, 3, 0, 3], 'border': [0, 1, 0, 1]})",
9092
\], 'XtestPopupBorder')
9193
let buf = RunVimInTerminal('-S XtestPopupBorder', {'rows': 15})
9294
call VerifyScreenDump(buf, 'Test_popupwin_2' .. iter, {})

src/version.c

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

778778
static int included_patches[] =
779779
{ /* Add new patch number below this line */
780+
/**/
781+
1550,
780782
/**/
781783
1549,
782784
/**/

0 commit comments

Comments
 (0)