summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-04-02 15:32:16 +0100
committerBram Moolenaar <Bram@vim.org>2022-04-02 15:32:16 +0100
commiteabddc425ea23fb91b3b0058ff01e9e4ede53351 (patch)
tree6309cd6ad8131fbc522749e7f9df2b0242cc5981 /src
parentc1658a196bb05dd96562fd0a92409be2201b62e9 (diff)
downloadvim-git-eabddc425ea23fb91b3b0058ff01e9e4ede53351.tar.gz
patch 8.2.4665: popup with "minwidth" and scrollbar not updated properlyv8.2.4665
Problem: Popup with "minwidth" and scrollbar not updated properly. Solution: Adjust the computation if the window width. (closes #10061)
Diffstat (limited to 'src')
-rw-r--r--src/popupwin.c38
-rw-r--r--src/testdir/dumps/Test_popupwin_drag_minwidth_1.dump10
-rw-r--r--src/testdir/dumps/Test_popupwin_drag_minwidth_2.dump10
-rw-r--r--src/testdir/dumps/Test_popupwin_drag_minwidth_3.dump10
-rw-r--r--src/testdir/dumps/Test_popupwin_previewpopup_10.dump12
-rw-r--r--src/testdir/dumps/Test_popupwin_previewpopup_4.dump12
-rw-r--r--src/testdir/dumps/Test_popupwin_previewpopup_5.dump12
-rw-r--r--src/testdir/dumps/Test_popupwin_previewpopup_7.dump12
-rw-r--r--src/testdir/dumps/Test_popupwin_previewpopup_8.dump12
-rw-r--r--src/testdir/dumps/Test_popupwin_previewpopup_9.dump12
-rw-r--r--src/testdir/test_popupwin.vim44
-rw-r--r--src/version.c2
12 files changed, 145 insertions, 41 deletions
diff --git a/src/popupwin.c b/src/popupwin.c
index 55f98f8a6..883372c47 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -1149,6 +1149,8 @@ popup_adjust_position(win_T *wp)
linenr_T lnum;
int wrapped = 0;
int maxwidth;
+ int maxwidth_no_scrollbar;
+ int width_with_scrollbar = 0;
int used_maxwidth = FALSE;
int margin_width = 0;
int maxspace;
@@ -1421,6 +1423,7 @@ popup_adjust_position(win_T *wp)
// Terminal window never has a scrollbar, adjusts to window height.
wp->w_has_scrollbar = FALSE;
#endif
+ maxwidth_no_scrollbar = maxwidth;
if (wp->w_has_scrollbar)
{
++right_extra;
@@ -1447,7 +1450,27 @@ popup_adjust_position(win_T *wp)
if (wp->w_width > maxspace && !wp->w_p_wrap)
// some columns cut off on the right
wp->w_popup_rightoff = wp->w_width - maxspace;
- wp->w_width = maxwidth;
+
+ // If the window doesn't fit because 'minwidth' is set then the
+ // scrollbar is at the far right of the screen, use the size without
+ // the scrollbar.
+ if (wp->w_has_scrollbar && wp->w_minwidth > 0)
+ {
+ int off = wp->w_width - maxwidth;
+
+ if (off > right_extra)
+ extra_width -= right_extra;
+ else
+ extra_width -= off;
+ wp->w_width = maxwidth_no_scrollbar;
+ }
+ else
+ {
+ wp->w_width = maxwidth;
+
+ // when adding a scrollbar below need to adjust the width
+ width_with_scrollbar = maxwidth_no_scrollbar - right_extra;
+ }
}
if (center_hor)
{
@@ -1535,7 +1558,8 @@ popup_adjust_position(win_T *wp)
else if (wp->w_popup_pos == POPPOS_TOPRIGHT
|| wp->w_popup_pos == POPPOS_TOPLEFT)
{
- if (wantline + (wp->w_height + extra_height) - 1 > Rows
+ if (wp != popup_dragwin
+ && wantline + (wp->w_height + extra_height) - 1 > Rows
&& wantline * 2 > Rows
&& (wp->w_popup_flags & POPF_POSINVERT))
{
@@ -1565,7 +1589,11 @@ popup_adjust_position(win_T *wp)
#ifdef FEAT_TERMINAL
if (wp->w_buffer->b_term == NULL)
#endif
+ {
wp->w_has_scrollbar = TRUE;
+ if (width_with_scrollbar > 0)
+ wp->w_width = width_with_scrollbar;
+ }
}
// make sure w_winrow is valid
@@ -3894,7 +3922,7 @@ update_popups(void (*win_update)(win_T *wp))
wp->w_flags |= WFLAG_WROW_OFF_ADDED;
}
- total_width = popup_width(wp);
+ total_width = popup_width(wp) - wp->w_popup_rightoff;
total_height = popup_height(wp);
popup_attr = get_wcr_attr(wp);
@@ -3989,7 +4017,7 @@ update_popups(void (*win_update)(win_T *wp))
? border_char[4] : border_char[0],
border_char[0], border_attr[0]);
}
- if (wp->w_popup_border[1] > 0 && wp->w_popup_rightoff == 0)
+ if (wp->w_popup_border[1] > 0)
{
buf[mb_char2bytes(border_char[5], buf)] = NUL;
screen_puts(buf, wp->w_winrow,
@@ -4039,7 +4067,7 @@ update_popups(void (*win_update)(win_T *wp))
--sb_thumb_height; // scrolled, no full thumb
if (sb_thumb_height == 0)
sb_thumb_height = 1;
- if (linecount <= wp->w_height)
+ if (linecount <= wp->w_height || wp->w_height == 0)
// it just fits, avoid divide by zero
sb_thumb_top = 0;
else
diff --git a/src/testdir/dumps/Test_popupwin_drag_minwidth_1.dump b/src/testdir/dumps/Test_popupwin_drag_minwidth_1.dump
new file mode 100644
index 000000000..fbeec7a90
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_drag_minwidth_1.dump
@@ -0,0 +1,10 @@
+>╔+0#0000001#ffd7ff255|═@73
+|║|0| @72
+|║|1| @72
+|║|2| @72
+|║|3| @72
+|║|4| @72
+|║|5| @72
+|║|6| @72
+|║|7| @72
+|║|8| @72
diff --git a/src/testdir/dumps/Test_popupwin_drag_minwidth_2.dump b/src/testdir/dumps/Test_popupwin_drag_minwidth_2.dump
new file mode 100644
index 000000000..b4edcfea0
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_drag_minwidth_2.dump
@@ -0,0 +1,10 @@
+> +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @26|╔+0#0000001#ffd7ff255|═@44|╗
+|~+0#4040ff13#ffffff0| @26|║+0#0000001#ffd7ff255|0| @42| +0#0000000#0000001|║+0#0000001#ffd7ff255
+|~+0#4040ff13#ffffff0| @26|║+0#0000001#ffd7ff255|1| @42| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
+|~+0#4040ff13#ffffff0| @26|║+0#0000001#ffd7ff255|2| @42| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
+|~+0#4040ff13#ffffff0| @26|║+0#0000001#ffd7ff255|3| @42| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
+| +0#0000000#ffffff0@27|╚+0#0000001#ffd7ff255|═@44|╝
diff --git a/src/testdir/dumps/Test_popupwin_drag_minwidth_3.dump b/src/testdir/dumps/Test_popupwin_drag_minwidth_3.dump
new file mode 100644
index 000000000..e429d3809
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_drag_minwidth_3.dump
@@ -0,0 +1,10 @@
+> +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @26|╔+0#0000001#ffd7ff255|═@44|╗
+|~+0#4040ff13#ffffff0| @26|║+0#0000001#ffd7ff255|0| @42| +0#0000000#0000001|║+0#0000001#ffd7ff255
+|~+0#4040ff13#ffffff0| @26|║+0#0000001#ffd7ff255|1| @42| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
+|~+0#4040ff13#ffffff0| @26|║+0#0000001#ffd7ff255|2| @42| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
+|~+0#4040ff13#ffffff0| @26|║+0#0000001#ffd7ff255|3| @42| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
+|~+0#4040ff13#ffffff0| @26|║+0#0000001#ffd7ff255|4| @42| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
+|~+0#4040ff13#ffffff0| @26|║+0#0000001#ffd7ff255|5| @42| +0#0000000#a8a8a8255|║+0#0000001#ffd7ff255
+| +0#0000000#ffffff0@27|╚+0#0000001#ffd7ff255|═@44|╝
diff --git a/src/testdir/dumps/Test_popupwin_previewpopup_10.dump b/src/testdir/dumps/Test_popupwin_previewpopup_10.dump
index 7003b43fd..fdf16b490 100644
--- a/src/testdir/dumps/Test_popupwin_previewpopup_10.dump
+++ b/src/testdir/dumps/Test_popupwin_previewpopup_10.dump
@@ -2,12 +2,12 @@
|#|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|⇲
+|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
diff --git a/src/testdir/dumps/Test_popupwin_previewpopup_4.dump b/src/testdir/dumps/Test_popupwin_previewpopup_4.dump
index 39ac485e1..dcec4edda 100644
--- a/src/testdir/dumps/Test_popupwin_previewpopup_4.dump
+++ b/src/testdir/dumps/Test_popupwin_previewpopup_4.dump
@@ -2,12 +2,12 @@
|#|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&#afffff255| |X|t|a|g|f|i|l|e| |═@29|X
-|s+0&#ffffff0|i|x| @29|║+0&#afffff255|2|7| @36| +0&#a8a8a8255|║+0&#afffff255
-|s+0&#ffffff0|e|v|e|n| @27|║+0&#afffff255|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |p|l|a|c|e| @17| +0&#a8a8a8255|║+0&#afffff255
-|f+0&#ffffff0|i|n|d| |t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e| @10|║+0&#afffff255|2|9| @36| +0&#0000001|║+0&#afffff255
-|n+0&#ffffff0|i|n|e| @28|║+0&#afffff255|3|0| @36| +0&#a8a8a8255|║+0&#afffff255
-|t+0&#ffffff0|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d| @12|╚+0&#afffff255|═@39|⇲
+|f|i|v|e| @27|╔+0&#afffff255| |X|t|a|g|f|i|l|e| |═@30|X
+|s+0&#ffffff0|i|x| @28|║+0&#afffff255|2|7| @37| +0&#a8a8a8255|║+0&#afffff255
+|s+0&#ffffff0|e|v|e|n| @26|║+0&#afffff255|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |p|l|a|c|e| @18| +0&#a8a8a8255|║+0&#afffff255
+|f+0&#ffffff0|i|n|d| |t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e| @9|║+0&#afffff255|2|9| @37| +0&#0000001|║+0&#afffff255
+|n+0&#ffffff0|i|n|e| @27|║+0&#afffff255|3|0| @37| +0&#a8a8a8255|║+0&#afffff255
+|t+0&#ffffff0|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d| @11|╚+0&#afffff255|═@40|⇲
|v+0&#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
diff --git a/src/testdir/dumps/Test_popupwin_previewpopup_5.dump b/src/testdir/dumps/Test_popupwin_previewpopup_5.dump
index 99c12c943..d26a7ed18 100644
--- a/src/testdir/dumps/Test_popupwin_previewpopup_5.dump
+++ b/src/testdir/dumps/Test_popupwin_previewpopup_5.dump
@@ -2,12 +2,12 @@
|#|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&#afffff255| |t|e|s|t|d|i|r|/|X|t|a|g|f|i|l|e| |═@21|X
-|s+0&#ffffff0|i|x| @29|║+0&#afffff255|2|7| @36| +0&#a8a8a8255|║+0&#afffff255
-|s+0&#ffffff0|e|v|e|n| @27|║+0&#afffff255|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |p|l|a|c|e| @17| +0&#a8a8a8255|║+0&#afffff255
-|f+0&#ffffff0|i|n|d| |t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e| @10|║+0&#afffff255|2|9| @36| +0&#0000001|║+0&#afffff255
-|n+0&#ffffff0|i|n|e| @28|║+0&#afffff255|3|0| @36| +0&#a8a8a8255|║+0&#afffff255
-|t+0&#ffffff0|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d| @12|╚+0&#afffff255|═@39|⇲
+|f|i|v|e| @27|╔+0&#afffff255| |t|e|s|t|d|i|r|/|X|t|a|g|f|i|l|e| |═@22|X
+|s+0&#ffffff0|i|x| @28|║+0&#afffff255|2|7| @37| +0&#a8a8a8255|║+0&#afffff255
+|s+0&#ffffff0|e|v|e|n| @26|║+0&#afffff255|t|h|i|s| |i|s| |a|n|o|t|h|e|r| |p|l|a|c|e| @18| +0&#a8a8a8255|║+0&#afffff255
+|f+0&#ffffff0|i|n|d| |t|h|e|w|o|r|d| |s|o|m|e|w|h|e|r|e| @9|║+0&#afffff255|2|9| @37| +0&#0000001|║+0&#afffff255
+|n+0&#ffffff0|i|n|e| @27|║+0&#afffff255|3|0| @37| +0&#a8a8a8255|║+0&#afffff255
+|t+0&#ffffff0|h|i|s| |i|s| |a|n|o|t|h|e|r| |w|o|r|d| @11|╚+0&#afffff255|═@40|⇲
|v+0&#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
diff --git a/src/testdir/dumps/Test_popupwin_previewpopup_7.dump b/src/testdir/dumps/Test_popupwin_previewpopup_7.dump
index add98bfcf..f510b8b77 100644
--- a/src/testdir/dumps/Test_popupwin_previewpopup_7.dump
+++ b/src/testdir/dumps/Test_popupwin_previewpopup_7.dump
@@ -2,12 +2,12 @@
|#|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|⇲
+|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
diff --git a/src/testdir/dumps/Test_popupwin_previewpopup_8.dump b/src/testdir/dumps/Test_popupwin_previewpopup_8.dump
index c5e75e19b..6e88fffca 100644
--- a/src/testdir/dumps/Test_popupwin_previewpopup_8.dump
+++ b/src/testdir/dumps/Test_popupwin_previewpopup_8.dump
@@ -2,12 +2,12 @@
|#|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|⇲
+|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
diff --git a/src/testdir/dumps/Test_popupwin_previewpopup_9.dump b/src/testdir/dumps/Test_popupwin_previewpopup_9.dump
index f555a00dc..09f8a45a1 100644
--- a/src/testdir/dumps/Test_popupwin_previewpopup_9.dump
+++ b/src/testdir/dumps/Test_popupwin_previewpopup_9.dump
@@ -2,12 +2,12 @@
|#|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|⇲
+|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
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index fda69921b..08f45ae22 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -616,6 +616,50 @@ func Test_popup_drag()
call delete('XtestPopupDrag')
endfunc
+func Test_popup_drag_minwidth()
+ CheckScreendump
+
+ " create a popup that does not fit
+ let lines =<< trim END
+ call range(40)
+ \ ->map({_,i -> string(i)})
+ \ ->popup_create({
+ \ 'drag': 1,
+ \ 'wrap': 0,
+ \ 'border': [],
+ \ 'scrollbar': 1,
+ \ 'minwidth': 100,
+ \ 'filter': {w, k -> k ==# 'q' ? len([popup_close(w)]) : 0},
+ \ })
+ func DragitDown()
+ map <silent> <F3> :call test_setmouse(1, 10)<CR>
+ map <silent> <F4> :call test_setmouse(5, 40)<CR>
+ call feedkeys("\<F3>\<LeftMouse>\<F4>\<LeftDrag>\<LeftRelease>", "xt")
+ endfunc
+ func DragitUp()
+ map <silent> <F3> :call test_setmouse(5, 40)<CR>
+ map <silent> <F4> :call test_setmouse(4, 40)<CR>
+ map <silent> <F5> :call test_setmouse(3, 40)<CR>
+ call feedkeys("\<F3>\<LeftMouse>\<F4>\<LeftDrag>\<F5>\<LeftDrag>\<LeftRelease>", "xt")
+ endfunc
+ END
+ call writefile(lines, 'XtestPopupDrag')
+ let buf = RunVimInTerminal('-S XtestPopupDrag', #{rows: 10})
+ call VerifyScreenDump(buf, 'Test_popupwin_drag_minwidth_1', {})
+
+ call term_sendkeys(buf, ":call DragitDown()\<CR>")
+ call VerifyScreenDump(buf, 'Test_popupwin_drag_minwidth_2', {})
+
+ call term_sendkeys(buf, ":call DragitUp()\<CR>")
+ call VerifyScreenDump(buf, 'Test_popupwin_drag_minwidth_3', {})
+
+ call term_sendkeys(buf, 'q')
+
+ " clean up
+ call StopVimInTerminal(buf)
+ call delete('XtestPopupDrag')
+endfunc
+
func Test_popup_drag_termwin()
CheckUnix
CheckScreendump
diff --git a/src/version.c b/src/version.c
index bb5fc9d8e..753eef303 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4665,
+/**/
4664,
/**/
4663,