summaryrefslogtreecommitdiff
path: root/src/popupwin.c
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 /src/popupwin.c
parentb2fe1d676f28af92989a842d4e8708dddf157b3d (diff)
downloadvim-git-7b3d93966709998011e2eb3b84414ff454161b37.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)
Diffstat (limited to 'src/popupwin.c')
-rw-r--r--src/popupwin.c11
1 files changed, 10 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;