Skip to content

Commit 331bafd

Browse files
committed
patch 8.1.1719: popup too wide when 'showbreak' is set
Problem: Popup too wide when 'showbreak' is set. Solution: Set window width when computing line length. (closes #4701)
1 parent cb5ff34 commit 331bafd

4 files changed

Lines changed: 43 additions & 3 deletions

File tree

src/popupwin.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -971,9 +971,16 @@ popup_adjust_position(win_T *wp)
971971
wp->w_width = 1;
972972
for (lnum = wp->w_topline; lnum <= wp->w_buffer->b_ml.ml_line_count; ++lnum)
973973
{
974-
// count Tabs for what they are worth
975-
int len = win_linetabsize(wp, ml_get_buf(wp->w_buffer, lnum, FALSE),
974+
int len;
975+
int w_width = wp->w_width;
976+
977+
// Count Tabs for what they are worth and compute the length based on
978+
// the maximum width (matters when 'showbreak' is set).
979+
if (wp->w_width < maxwidth)
980+
wp->w_width = maxwidth;
981+
len = win_linetabsize(wp, ml_get_buf(wp->w_buffer, lnum, FALSE),
976982
(colnr_T)MAXCOL);
983+
wp->w_width = w_width;
977984

978985
if (wp->w_p_wrap)
979986
{
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
>1+0&#ffffff0| @73
2+
|2| @73
3+
|3| @73
4+
|4| @25|╔+0#0000001#ffd7ff255|═@17|╗| +0#0000000#ffffff0@27
5+
|5| @25|║+0#0000001#ffd7ff255| |a| |l|o|n|g| |l|i|n|e| |h|e|r|e| |║| +0#0000000#ffffff0@27
6+
|6| @25|╚+0#0000001#ffd7ff255|═@17|╝| +0#0000000#ffffff0@27
7+
|7| @73
8+
|8| @73
9+
|9| @73
10+
@57|1|,|1| @10|T|o|p|

src/testdir/test_popupwin.vim

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,27 @@ func Test_popup_without_wrap()
717717
call delete('XtestPopup')
718718
endfunc
719719

720+
func Test_popup_with_showbreak()
721+
if !CanRunVimInTerminal()
722+
throw 'Skipped: cannot make screendumps'
723+
endif
724+
let lines =<< trim END
725+
set showbreak=>>\
726+
call setline(1, range(1, 20))
727+
let winid = popup_dialog(
728+
\ 'a long line here',
729+
\ #{filter: 'popup_filter_yesno'})
730+
END
731+
call writefile(lines, 'XtestPopupShowbreak')
732+
let buf = RunVimInTerminal('-S XtestPopupShowbreak', #{rows: 10})
733+
call VerifyScreenDump(buf, 'Test_popupwin_showbreak', {})
734+
735+
" clean up
736+
call term_sendkeys(buf, "y")
737+
call StopVimInTerminal(buf)
738+
call delete('XtestPopupShowbreak')
739+
endfunc
740+
720741
func Test_popup_time()
721742
if !has('timers')
722743
throw 'Skipped: timer feature not supported'
@@ -2162,4 +2183,4 @@ func Test_previewpopup()
21622183
call delete('XtestPreviewPopup')
21632184
endfunc
21642185

2165-
" vim: shiftwidth=2 sts=2 expandtab
2186+
" vim: shiftwidth=2 sts=2

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+
1719,
780782
/**/
781783
1718,
782784
/**/

0 commit comments

Comments
 (0)