summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-10-16 22:17:07 +0200
committerBram Moolenaar <Bram@vim.org>2019-10-16 22:17:07 +0200
commit7b3d93966709998011e2eb3b84414ff454161b37 (patch)
treef5f4d431fb4460b32784b72c90c21d94e1cfa230
parentb2fe1d676f28af92989a842d4e8708dddf157b3d (diff)
downloadvim-git-8.1.2164.tar.gz
patch 8.1.2164: stuck when using "j" in a popupwin with popup_filter_menuv8.1.2164
Problem: Stuck when using "j" in a popupwin with popup_filter_menu if a line wraps. Solution: Check the cursor line is visible. (closes #4577)
-rw-r--r--src/popupwin.c11
-rw-r--r--src/testdir/dumps/Test_popupwin_wrap_1.dump10
-rw-r--r--src/testdir/dumps/Test_popupwin_wrap_2.dump10
-rw-r--r--src/testdir/test_popupwin.vim32
-rw-r--r--src/version.c2
5 files changed, 64 insertions, 1 deletions
diff --git a/src/popupwin.c b/src/popupwin.c
index 6b0b383b0..f9c127a6c 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -535,7 +535,7 @@ check_highlight(dict_T *dict, char *name, char_u **pval)
}
/*
- * Scroll to show the line with the cursor. This assumes lines don't wrap.
+ * Scroll to show the line with the cursor.
*/
static void
popup_show_curline(win_T *wp)
@@ -550,6 +550,11 @@ popup_show_curline(win_T *wp)
wp->w_topline = 1;
else if (wp->w_topline > wp->w_buffer->b_ml.ml_line_count)
wp->w_topline = wp->w_buffer->b_ml.ml_line_count;
+ while (wp->w_topline < wp->w_cursor.lnum
+ && wp->w_topline < wp->w_buffer->b_ml.ml_line_count
+ && plines_m_win(wp, wp->w_topline, wp->w_cursor.lnum)
+ > wp->w_height)
+ ++wp->w_topline;
}
// Don't use "firstline" now.
@@ -1041,6 +1046,7 @@ popup_adjust_position(win_T *wp)
linenr_T lnum;
int wrapped = 0;
int maxwidth;
+ int used_maxwidth = FALSE;
int maxspace;
int center_vert = FALSE;
int center_hor = FALSE;
@@ -1208,6 +1214,7 @@ popup_adjust_position(win_T *wp)
++wrapped;
len -= maxwidth;
wp->w_width = maxwidth;
+ used_maxwidth = TRUE;
}
}
else if (len > maxwidth
@@ -1259,6 +1266,8 @@ popup_adjust_position(win_T *wp)
{
++right_extra;
++extra_width;
+ if (used_maxwidth)
+ maxwidth -= 2; // try to show the scrollbar
}
minwidth = wp->w_minwidth;
diff --git a/src/testdir/dumps/Test_popupwin_wrap_1.dump b/src/testdir/dumps/Test_popupwin_wrap_1.dump
new file mode 100644
index 000000000..5643dc75c
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_wrap_1.dump
@@ -0,0 +1,10 @@
+>1+0&#ffffff0| @73
+|2| @73
+|╔+0#0000001#ffd7ff255|═@73
+|║| |o+0&#e0e0e08|n|e| @67| +0&#ffd7ff255| +0#0000000#0000001
+|║+0#0000001#ffd7ff255| |a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d| | +0#0000000#0000001
+|║+0#0000001#ffd7ff255| |f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s| @52| +0#0000000#a8a8a8255
+|╚+0#0000001#ffd7ff255|═@73
+|8+0#0000000#ffffff0| @73
+|9| @73
+@57|1|,|1| @10|T|o|p|
diff --git a/src/testdir/dumps/Test_popupwin_wrap_2.dump b/src/testdir/dumps/Test_popupwin_wrap_2.dump
new file mode 100644
index 000000000..3a02fc5c9
--- /dev/null
+++ b/src/testdir/dumps/Test_popupwin_wrap_2.dump
@@ -0,0 +1,10 @@
+>1+0&#ffffff0| @73
+|2| @73
+|╔+0#0000001#ffd7ff255|═@73
+|║| |a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d| | +0#0000000#a8a8a8255
+|║+0#0000001#ffd7ff255| |f|a|s|d|f|a|s|d|f|a|s|d|f|a|s|d|f|a|s| @52| +0#0000000#0000001
+|║+0#0000001#ffd7ff255| |t+0&#e0e0e08|h|r|e@1| @65| +0&#ffd7ff255| +0#0000000#0000001
+|╚+0#0000001#ffd7ff255|═@73
+|8+0#0000000#ffffff0| @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 771db9a69..e84527bf7 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -509,6 +509,38 @@ func Test_popup_close_with_mouse()
call delete('XtestPopupClose')
endfunction
+func Test_popup_menu_wrap()
+ CheckScreendump
+
+ let lines =<< trim END
+ call setline(1, range(1, 20))
+ call popup_create([
+ \ 'one',
+ \ 'asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfas',
+ \ 'three',
+ \ 'four',
+ \ ], #{
+ \ pos: "botleft",
+ \ border: [],
+ \ padding: [0,1,0,1],
+ \ maxheight: 3,
+ \ cursorline: 1,
+ \ filter: 'popup_filter_menu',
+ \ })
+ END
+ call writefile(lines, 'XtestPopupWrap')
+ let buf = RunVimInTerminal('-S XtestPopupWrap', #{rows: 10})
+ call VerifyScreenDump(buf, 'Test_popupwin_wrap_1', {})
+
+ call term_sendkeys(buf, "jj")
+ call VerifyScreenDump(buf, 'Test_popupwin_wrap_2', {})
+
+ " clean up
+ call term_sendkeys(buf, "\<Esc>")
+ call StopVimInTerminal(buf)
+ call delete('XtestPopupWrap')
+endfunction
+
func Test_popup_with_mask()
CheckScreendump
diff --git a/src/version.c b/src/version.c
index cfd54a19c..f6a3817da 100644
--- a/src/version.c
+++ b/src/version.c
@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2164,
+/**/
2163,
/**/
2162,