Patch 8.1.2240
Problem: Popup window width changes when scrolling.
Solution: Also adjust maxwidth when applying minwidth and there is a
scrollbar. Fix off-by-one error. (closes #5162)
Files: src/popupwin.c, src/testdir/test_popupwin.vim,
src/testdir/dumps/Test_popupwin_scroll_11.dump,
src/testdir/dumps/Test_popupwin_scroll_12.dump,
src/testdir/dumps/Test_popupwin_previewpopup_4.dump,
src/testdir/dumps/Test_popupwin_previewpopup_5.dump,
src/testdir/dumps/Test_popupwin_previewpopup_7.dump,
src/testdir/dumps/Test_popupwin_previewpopup_8.dump,
*** ../vim-8.1.2239/src/popupwin.c 2019-10-24 22:12:51.569124167 +0200
--- src/popupwin.c 2019-11-02 20:04:36.266139166 +0100
***************
*** 1201,1206 ****
--- 1201,1207 ----
allow_adjust_left = FALSE;
maxwidth = wp->w_maxwidth;
}
+ minwidth = wp->w_minwidth;
// start at the desired first line
if (wp->w_firstline > 0)
***************
*** 1270,1287 ****
if (wp->w_maxwidth > 0 && wp->w_width > wp->w_maxwidth)
wp->w_width = wp->w_maxwidth;
}
// do not use the width of lines we're not going to show
if (wp->w_maxheight > 0
&& (wp->w_firstline >= 0
? lnum - wp->w_topline
: wp->w_buffer->b_ml.ml_line_count - lnum)
! + 1 + wrapped > wp->w_maxheight)
break;
-
- if (wp->w_firstline < 0)
- --lnum;
- else
- ++lnum;
}
if (wp->w_firstline < 0)
--- 1271,1289 ----
if (wp->w_maxwidth > 0 && wp->w_width > wp->w_maxwidth)
wp->w_width = wp->w_maxwidth;
}
+
+ if (wp->w_firstline < 0)
+ --lnum;
+ else
+ ++lnum;
+
// do not use the width of lines we're not going to show
if (wp->w_maxheight > 0
&& (wp->w_firstline >= 0
? lnum - wp->w_topline
: wp->w_buffer->b_ml.ml_line_count - lnum)
! + wrapped >= wp->w_maxheight)
break;
}
if (wp->w_firstline < 0)
***************
*** 1293,1303 ****
{
++right_extra;
++extra_width;
! if (used_maxwidth)
! maxwidth -= 2; // try to show the scrollbar
}
- minwidth = wp->w_minwidth;
if (wp->w_popup_title != NULL && *wp->w_popup_title != NUL)
{
int title_len = vim_strsize(wp->w_popup_title) + 2 - extra_width;
--- 1295,1307 ----
{
++right_extra;
++extra_width;
! // make space for the scrollbar if needed, when lines wrap and when
! // applying minwidth
! if (maxwidth + right_extra >= maxspace
! && (used_maxwidth || (minwidth > 0 && wp->w_width < minwidth)))
! maxwidth -= wp->w_popup_padding[1] + 1;
}
if (wp->w_popup_title != NULL && *wp->w_popup_title != NUL)
{
int title_len = vim_strsize(wp->w_popup_title) + 2 - extra_width;
*** ../vim-8.1.2239/src/testdir/test_popupwin.vim 2019-10-24
19:24:56.531366030 +0200
--- src/testdir/test_popupwin.vim 2019-11-02 15:48:32.833080601 +0100
***************
*** 1764,1769 ****
--- 1764,1805 ----
call popup_setoptions(g:winid, #{border: [], close: 'button'})
call feedkeys("\<F5>\<LeftMouse>", "xt")
endfunc
+ func Popup_filter(winid, key)
+ if a:key == 'j'
+ let line = popup_getoptions(a:winid).firstline
+ let nlines = line('$', a:winid)
+ let newline = line < nlines ? (line + 1) : nlines
+ call popup_setoptions(a:winid, #{firstline: newline})
+ return v:true
+ elseif a:key == 'x'
+ call popup_close(a:winid)
+ return v:true
+ endif
+ endfunc
+
+ func PopupScroll()
+ call popup_clear()
+ let text =<< trim END
+ 1
+ 2
+ 3
+ 4
+ long line long line long line long line long line long line
+ long line long line long line long line long line long line
+ long line long line long line long line long line long line
+ END
+ call popup_create(text, #{
+ \ minwidth: 30,
+ \ maxwidth: 30,
+ \ minheight: 4,
+ \ maxheight: 4,
+ \ firstline: 1,
+ \ wrap: v:true,
+ \ scrollbar: v:true,
+ \ mapping: v:false,
+ \ filter: funcref('Popup_filter')
+ \ })
+ endfunc
map <silent> <F3> :call test_setmouse(5, 36)<CR>
map <silent> <F4> :call test_setmouse(4, 42)<CR>
map <silent> <F5> :call test_setmouse(7, 42)<CR>
***************
*** 1811,1816 ****
--- 1847,1861 ----
call term_sendkeys(buf, ":\<CR>")
call VerifyScreenDump(buf, 'Test_popupwin_scroll_10', {})
+ " check size with non-wrapping lines
+ call term_sendkeys(buf, ":call PopupScroll()\<CR>")
+ call VerifyScreenDump(buf, 'Test_popupwin_scroll_11', {})
+
+ " check size with wrapping lines
+ call term_sendkeys(buf, "j")
+ call VerifyScreenDump(buf, 'Test_popupwin_scroll_12', {})
+ call term_sendkeys(buf, "x")
+
" clean up
call StopVimInTerminal(buf)
call delete('XtestPopupScroll')
*** ../vim-8.1.2239/src/testdir/dumps/Test_popupwin_scroll_11.dump
2019-11-02 20:20:03.190886212 +0100
--- src/testdir/dumps/Test_popupwin_scroll_11.dump 2019-11-02
16:12:48.223660228 +0100
***************
*** 0 ****
--- 1,10 ----
+ >1+0&#ffffff0| @73
+ |2| @73
+ |3| @73
+ |4| @20|1+0#0000001#ffd7ff255| @28| +0#0000000#0000001| +0&#ffffff0@21
+ |5| @20|2+0#0000001#ffd7ff255| @28| +0#0000000#0000001| +0&#ffffff0@21
+ |6| @20|3+0#0000001#ffd7ff255| @28| +0#0000000#a8a8a8255| +0&#ffffff0@21
+ |7| @20|4+0#0000001#ffd7ff255| @28| +0#0000000#a8a8a8255| +0&#ffffff0@21
+ |8| @73
+ |9| @73
+ |:|c|a|l@1| |P|o|p|u|p|S|c|r|o|l@1|(|)| @37|1|,|1| @10|T|o|p|
*** ../vim-8.1.2239/src/testdir/dumps/Test_popupwin_scroll_12.dump
2019-11-02 20:20:03.194886224 +0100
--- src/testdir/dumps/Test_popupwin_scroll_12.dump 2019-11-02
16:12:49.279656117 +0100
***************
*** 0 ****
--- 1,10 ----
+ >1+0&#ffffff0| @73
+ |2| @73
+ |3| @73
+ |4| @20|2+0#0000001#ffd7ff255| @28| +0#0000000#a8a8a8255| +0&#ffffff0@21
+ |5| @20|3+0#0000001#ffd7ff255| @28| +0#0000000#0000001| +0&#ffffff0@21
+ |6| @20|4+0#0000001#ffd7ff255| @28| +0#0000000#0000001| +0&#ffffff0@21
+ |7| @20|l+0#0000001#ffd7ff255|o|n|g| |l|i|n|e| |l|o|n|g| |l|i|n|e| |l|o|n|g|
|l|i|n|e| | +0#0000000#a8a8a8255| +0&#ffffff0@21
+ |8| @73
+ |9| @73
+ |:|c|a|l@1| |P|o|p|u|p|S|c|r|o|l@1|(|)| @37|1|,|1| @10|T|o|p|
*** ../vim-8.1.2239/src/testdir/dumps/Test_popupwin_previewpopup_4.dump
2019-08-08 21:52:35.518263963 +0200
--- src/testdir/dumps/Test_popupwin_previewpopup_4.dump 2019-11-02
19:26:48.742323594 +0100
***************
*** 2,13 ****
|#|i|n|c|l|u|d|e| |"|X|h|e|a|d|e|r|.|h|"| @54
|t|h|r|e@1| @69
|f|o|u|r| @70
! |f|i|v|e| @27|╔+0#0000001#ffd7ff255| |X|t|a|g|f|i|l|e| |═@30|X
! |s+0#0000000#ffffff0|i|x| @28|║+0#0000001#ffd7ff255|2|7| @37|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |s+0#0000000#ffffff0|e|v|e|n| @26|║+0#0000001#ffd7ff255|t|h|i|s| |i|s|
|a|n|o|t|h|e|r| |p|l|a|c|e| @18| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |f+0#0000000#ffffff0|i|n|d| |t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e|
@9|║+0#0000001#ffd7ff255|2|9| @37| +0#0000000#0000001|║+0#0000001#ffd7ff255
! |n+0#0000000#ffffff0|i|n|e| @27|║+0#0000001#ffd7ff255|3|0| @37|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |t+0#0000000#ffffff0|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d|
@11|╚+0#0000001#ffd7ff255|═@40|⇲
|v+0#0000000#ffffff0|e|r|y| |l|o|n|g| |l|i|n|e| |w|h|e|r|e| |t|h|e| |w|o|r|d|
|i|s| |a|l|s|o| >a|n|o|t|h|e|r| @29
|~+0#4040ff13&| @73
|~| @73
--- 2,13 ----
|#|i|n|c|l|u|d|e| |"|X|h|e|a|d|e|r|.|h|"| @54
|t|h|r|e@1| @69
|f|o|u|r| @70
! |f|i|v|e| @28|╔+0#0000001#ffd7ff255| |X|t|a|g|f|i|l|e| |═@29|X
! |s+0#0000000#ffffff0|i|x| @29|║+0#0000001#ffd7ff255|2|7| @36|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |s+0#0000000#ffffff0|e|v|e|n| @27|║+0#0000001#ffd7ff255|t|h|i|s| |i|s|
|a|n|o|t|h|e|r| |p|l|a|c|e| @17| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |f+0#0000000#ffffff0|i|n|d| |t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e|
@10|║+0#0000001#ffd7ff255|2|9| @36| +0#0000000#0000001|║+0#0000001#ffd7ff255
! |n+0#0000000#ffffff0|i|n|e| @28|║+0#0000001#ffd7ff255|3|0| @36|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |t+0#0000000#ffffff0|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d|
@12|╚+0#0000001#ffd7ff255|═@39|⇲
|v+0#0000000#ffffff0|e|r|y| |l|o|n|g| |l|i|n|e| |w|h|e|r|e| |t|h|e| |w|o|r|d|
|i|s| |a|l|s|o| >a|n|o|t|h|e|r| @29
|~+0#4040ff13&| @73
|~| @73
*** ../vim-8.1.2239/src/testdir/dumps/Test_popupwin_previewpopup_5.dump
2019-08-08 21:52:35.518263963 +0200
--- src/testdir/dumps/Test_popupwin_previewpopup_5.dump 2019-11-02
19:52:27.921986112 +0100
***************
*** 2,13 ****
|#|i|n|c|l|u|d|e| |"|X|h|e|a|d|e|r|.|h|"| @54
|t|h|r|e@1| @69
|f|o|u|r| @70
! |f|i|v|e| @27|╔+0#0000001#ffd7ff255| |t|e|s|t|d|i|r|/|X|t|a|g|f|i|l|e| |═@22|X
! |s+0#0000000#ffffff0|i|x| @28|║+0#0000001#ffd7ff255|2|7| @37|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |s+0#0000000#ffffff0|e|v|e|n| @26|║+0#0000001#ffd7ff255|t|h|i|s| |i|s|
|a|n|o|t|h|e|r| |p|l|a|c|e| @18| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |f+0#0000000#ffffff0|i|n|d| |t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e|
@9|║+0#0000001#ffd7ff255|2|9| @37| +0#0000000#0000001|║+0#0000001#ffd7ff255
! |n+0#0000000#ffffff0|i|n|e| @27|║+0#0000001#ffd7ff255|3|0| @37|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |t+0#0000000#ffffff0|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d|
@11|╚+0#0000001#ffd7ff255|═@40|⇲
|v+0#0000000#ffffff0|e|r|y| |l|o|n|g| |l|i|n|e| |w|h|e|r|e| |t|h|e| |w|o|r|d|
|i|s| |a|l|s|o| >a|n|o|t|h|e|r| @29
|~+0#4040ff13&| @73
|~| @73
--- 2,13 ----
|#|i|n|c|l|u|d|e| |"|X|h|e|a|d|e|r|.|h|"| @54
|t|h|r|e@1| @69
|f|o|u|r| @70
! |f|i|v|e| @28|╔+0#0000001#ffd7ff255| |t|e|s|t|d|i|r|/|X|t|a|g|f|i|l|e| |═@21|X
! |s+0#0000000#ffffff0|i|x| @29|║+0#0000001#ffd7ff255|2|7| @36|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |s+0#0000000#ffffff0|e|v|e|n| @27|║+0#0000001#ffd7ff255|t|h|i|s| |i|s|
|a|n|o|t|h|e|r| |p|l|a|c|e| @17| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |f+0#0000000#ffffff0|i|n|d| |t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e|
@10|║+0#0000001#ffd7ff255|2|9| @36| +0#0000000#0000001|║+0#0000001#ffd7ff255
! |n+0#0000000#ffffff0|i|n|e| @28|║+0#0000001#ffd7ff255|3|0| @36|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |t+0#0000000#ffffff0|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d|
@12|╚+0#0000001#ffd7ff255|═@39|⇲
|v+0#0000000#ffffff0|e|r|y| |l|o|n|g| |l|i|n|e| |w|h|e|r|e| |t|h|e| |w|o|r|d|
|i|s| |a|l|s|o| >a|n|o|t|h|e|r| @29
|~+0#4040ff13&| @73
|~| @73
*** ../vim-8.1.2239/src/testdir/dumps/Test_popupwin_previewpopup_7.dump
2019-08-05 21:51:36.801568843 +0200
--- src/testdir/dumps/Test_popupwin_previewpopup_7.dump 2019-11-02
15:56:47.143332795 +0100
***************
*** 2,13 ****
|#|i|n|c|l|u|d|e| |"|X|h|e|a|d|e|r|.|h|"| @54
|t|h|r|e@1| @69
|f|o|u|r| @70
! |f|i|v|e| @27|╔+0#0000001#ffd7ff255| |X|t|a|g|f|i|l|e| |═@30|X
! |s+0#0000000#ffffff0|i|x| @28|║+0#0000001#ffd7ff255|2|0| @37|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |s+0#0000000#ffffff0|e|v|e|n| @26|║+0#0000001#ffd7ff255|t|h|e|w|o|r|d| |i|s|
|h|e|r|e| @24| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |f+0#0000000#ffffff0|i|n|d| |t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e|
@9|║+0#0000001#ffd7ff255|2@1| @37| +0#0000000#0000001|║+0#0000001#ffd7ff255
! |n+0#0000000#ffffff0|i|n|e| @27|║+0#0000001#ffd7ff255|2|3| @37|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |t+0#0000000#ffffff0|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d|
@11|╚+0#0000001#ffd7ff255|═@40|⇲
|v+0#0000000#ffffff0|e|r|y| |l|o|n|g| |l|i|n|e| |w|h|e|r|e| |t|h|e| |w|o|r|d|
|i|s| |a|l|s|o| >a|n|o|t|h|e|r| @29
|~+0#4040ff13&| @73
|~| @73
--- 2,13 ----
|#|i|n|c|l|u|d|e| |"|X|h|e|a|d|e|r|.|h|"| @54
|t|h|r|e@1| @69
|f|o|u|r| @70
! |f|i|v|e| @28|╔+0#0000001#ffd7ff255| |X|t|a|g|f|i|l|e| |═@29|X
! |s+0#0000000#ffffff0|i|x| @29|║+0#0000001#ffd7ff255|2|0| @36|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |s+0#0000000#ffffff0|e|v|e|n| @27|║+0#0000001#ffd7ff255|t|h|e|w|o|r|d| |i|s|
|h|e|r|e| @23| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |f+0#0000000#ffffff0|i|n|d| |t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e|
@10|║+0#0000001#ffd7ff255|2@1| @36| +0#0000000#0000001|║+0#0000001#ffd7ff255
! |n+0#0000000#ffffff0|i|n|e| @28|║+0#0000001#ffd7ff255|2|3| @36|
+0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |t+0#0000000#ffffff0|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d|
@12|╚+0#0000001#ffd7ff255|═@39|⇲
|v+0#0000000#ffffff0|e|r|y| |l|o|n|g| |l|i|n|e| |w|h|e|r|e| |t|h|e| |w|o|r|d|
|i|s| |a|l|s|o| >a|n|o|t|h|e|r| @29
|~+0#4040ff13&| @73
|~| @73
*** ../vim-8.1.2239/src/testdir/dumps/Test_popupwin_previewpopup_8.dump
2019-08-05 21:51:36.801568843 +0200
--- src/testdir/dumps/Test_popupwin_previewpopup_8.dump 2019-11-02
15:56:48.195328909 +0100
***************
*** 2,13 ****
|#|i|n|c|l|u|d|e| |"|X|h|e|a|d|e|r|.|h|"| @54
|t|h|r|e@1| @69
|f|o|u|r| @70
! |f|i|v|e| @27|╔+0#0000001#ffd7ff255| |X|h|e|a|d|e|r|.|h| |═@29|X
! |s+0#0000000#ffffff0|i|x| @28|║+0#0000001#ffd7ff255|1+0#e000002&|0|
+0#0000001&@37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |s+0#0000000#ffffff0|e|v|e|n| @26|║+0#0000001#ffd7ff255|s|e|a|r|c|h|e|d|
|w|o|r|d| |i|s| |h|e|r|e| @18| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |f+0#0000000#ffffff0|i|n|d| |t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e|
@9|║+0#0000001#ffd7ff255|1+0#e000002&|2| +0#0000001&@37|
+0#0000000#0000001|║+0#0000001#ffd7ff255
! |n+0#0000000#ffffff0|i|n|e| @27|║+0#0000001#ffd7ff255|1+0#e000002&|3|
+0#0000001&@37| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |t+0#0000000#ffffff0|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d|
@11|╚+0#0000001#ffd7ff255|═@40|⇲
|v+0#0000000#ffffff0|e|r|y| |l|o|n|g| |l|i|n|e| |w|h|e|r|e| |t|h|e| |w|o|r|d|
|i|s| |a|l|s|o| >a|n|o|t|h|e|r| @29
|~+0#4040ff13&| @73
|~| @73
--- 2,13 ----
|#|i|n|c|l|u|d|e| |"|X|h|e|a|d|e|r|.|h|"| @54
|t|h|r|e@1| @69
|f|o|u|r| @70
! |f|i|v|e| @28|╔+0#0000001#ffd7ff255| |X|h|e|a|d|e|r|.|h| |═@28|X
! |s+0#0000000#ffffff0|i|x| @29|║+0#0000001#ffd7ff255|1+0#e000002&|0|
+0#0000001&@36| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |s+0#0000000#ffffff0|e|v|e|n| @27|║+0#0000001#ffd7ff255|s|e|a|r|c|h|e|d|
|w|o|r|d| |i|s| |h|e|r|e| @17| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |f+0#0000000#ffffff0|i|n|d| |t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e|
@10|║+0#0000001#ffd7ff255|1+0#e000002&|2| +0#0000001&@36|
+0#0000000#0000001|║+0#0000001#ffd7ff255
! |n+0#0000000#ffffff0|i|n|e| @28|║+0#0000001#ffd7ff255|1+0#e000002&|3|
+0#0000001&@36| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
! |t+0#0000000#ffffff0|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d|
@12|╚+0#0000001#ffd7ff255|═@39|⇲
|v+0#0000000#ffffff0|e|r|y| |l|o|n|g| |l|i|n|e| |w|h|e|r|e| |t|h|e| |w|o|r|d|
|i|s| |a|l|s|o| >a|n|o|t|h|e|r| @29
|~+0#4040ff13&| @73
|~| @73
*** ../vim-8.1.2239/src/version.c 2019-11-02 18:22:04.479206505 +0100
--- src/version.c 2019-11-02 20:08:10.453009542 +0100
***************
*** 743,744 ****
--- 743,746 ----
{ /* Add new patch number below this line */
+ /**/
+ 2240,
/**/
--
Don't Panic!
-- The Hitchhiker's Guide to the Galaxy
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/201911021921.xA2JLssg021826%40masaka.moolenaar.net.