diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-07-20 17:46:05 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-07-20 17:46:05 +0200 |
commit | 331bafd481fddfe542099d8cccd38d240c10c011 (patch) | |
tree | 45171a423c6c97bf8a5cd0bb22bf37196b204ca8 /src | |
parent | cb5ff34c1b8a89fcdb86653ab18d0aa53f665642 (diff) |
patch 8.1.1719: popup too wide when 'showbreak' is setv8.1.1719
Problem: Popup too wide when 'showbreak' is set.
Solution: Set window width when computing line length. (closes #4701)
Diffstat (limited to 'src')
-rw-r--r-- | src/popupwin.c | 11 | ||||
-rw-r--r-- | src/testdir/dumps/Test_popupwin_showbreak.dump | 10 | ||||
-rw-r--r-- | src/testdir/test_popupwin.vim | 23 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 43 insertions, 3 deletions
diff --git a/src/popupwin.c b/src/popupwin.c index d22c00dcdb..a303582be6 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -971,9 +971,16 @@ popup_adjust_position(win_T *wp) wp->w_width = 1; for (lnum = wp->w_topline; lnum <= wp->w_buffer->b_ml.ml_line_count; ++lnum) { - // count Tabs for what they are worth - int len = win_linetabsize(wp, ml_get_buf(wp->w_buffer, lnum, FALSE), + int len; + int w_width = wp->w_width; + + // Count Tabs for what they are worth and compute the length based on + // the maximum width (matters when 'showbreak' is set). + if (wp->w_width < maxwidth) + wp->w_width = maxwidth; + len = win_linetabsize(wp, ml_get_buf(wp->w_buffer, lnum, FALSE), (colnr_T)MAXCOL); + wp->w_width = w_width; if (wp->w_p_wrap) { diff --git a/src/testdir/dumps/Test_popupwin_showbreak.dump b/src/testdir/dumps/Test_popupwin_showbreak.dump new file mode 100644 index 0000000000..e7d03d05cd --- /dev/null +++ b/src/testdir/dumps/Test_popupwin_showbreak.dump @@ -0,0 +1,10 @@ +>1+0&#ffffff0| @73 +|2| @73 +|3| @73 +|4| @25|╔+0#0000001#ffd7ff255|═@17|╗| +0#0000000#ffffff0@27 +|5| @25|║+0#0000001#ffd7ff255| |a| |l|o|n|g| |l|i|n|e| |h|e|r|e| |║| +0#0000000#ffffff0@27 +|6| @25|╚+0#0000001#ffd7ff255|═@17|╝| +0#0000000#ffffff0@27 +|7| @73 +|8| @73 +|9| @73 +@57|1|,|1| @10|T|o|p| diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim index 11e4323b9b..20c175aae4 100644 --- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -717,6 +717,27 @@ func Test_popup_without_wrap() call delete('XtestPopup') endfunc +func Test_popup_with_showbreak() + if !CanRunVimInTerminal() + throw 'Skipped: cannot make screendumps' + endif + let lines =<< trim END + set showbreak=>>\ + call setline(1, range(1, 20)) + let winid = popup_dialog( + \ 'a long line here', + \ #{filter: 'popup_filter_yesno'}) + END + call writefile(lines, 'XtestPopupShowbreak') + let buf = RunVimInTerminal('-S XtestPopupShowbreak', #{rows: 10}) + call VerifyScreenDump(buf, 'Test_popupwin_showbreak', {}) + + " clean up + call term_sendkeys(buf, "y") + call StopVimInTerminal(buf) + call delete('XtestPopupShowbreak') +endfunc + func Test_popup_time() if !has('timers') throw 'Skipped: timer feature not supported' @@ -2162,4 +2183,4 @@ func Test_previewpopup() call delete('XtestPreviewPopup') endfunc -" vim: shiftwidth=2 sts=2 expandtab +" vim: shiftwidth=2 sts=2 diff --git a/src/version.c b/src/version.c index e9e0446587..0de9887235 100644 --- a/src/version.c +++ b/src/version.c @@ -778,6 +778,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1719, +/**/ 1718, /**/ 1717, |