summaryrefslogtreecommitdiff
path: root/src/popupmnu.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-02-24 21:25:44 +0100
committerBram Moolenaar <Bram@vim.org>2018-02-24 21:25:44 +0100
commit2b10bcbfc1c025bf7e6358326ee70105e7d30e96 (patch)
treebb749db849a551b73f39c1111351118c06edc372 /src/popupmnu.c
parent6bb2cdfe604e51eec216cbe23bb6e8fb47810347 (diff)
downloadvim-git-2b10bcbfc1c025bf7e6358326ee70105e7d30e96.tar.gz
patch 8.0.1540: popup menu positioning fails with longer stringv8.0.1540
Problem: Popup menu positioning fails with longer string. Solution: Only align with right side of window when width is less than 'pumwidth' (closes #2661)
Diffstat (limited to 'src/popupmnu.c')
-rw-r--r--src/popupmnu.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/popupmnu.c b/src/popupmnu.c
index 6ac121d91..d9def3664 100644
--- a/src/popupmnu.c
+++ b/src/popupmnu.c
@@ -69,7 +69,7 @@ pum_compute_size(void)
/*
* Show the popup menu with items "array[size]".
* "array" must remain valid until pum_undisplay() is called!
- * When possible the leftmost character is aligned with screen column "col".
+ * When possible the leftmost character is aligned with cursor column.
* The menu appears above the screen line "row" or at "row" + "height" - 1.
*/
void
@@ -83,7 +83,7 @@ pum_display(
int max_width;
int row;
int context_lines;
- int col;
+ int cursor_col;
int above_row;
int below_row;
int redo_count = 0;
@@ -199,10 +199,11 @@ pum_display(
/* Calculate column */
#ifdef FEAT_RIGHTLEFT
if (curwin->w_p_rl)
- col = curwin->w_wincol + curwin->w_width - curwin->w_wcol - 1;
+ cursor_col = curwin->w_wincol + curwin->w_width
+ - curwin->w_wcol - 1;
else
#endif
- col = curwin->w_wincol + curwin->w_wcol;
+ cursor_col = curwin->w_wincol + curwin->w_wcol;
/* if there are more items than room we need a scrollbar */
if (pum_height < size)
@@ -216,15 +217,17 @@ pum_display(
if (def_width < max_width)
def_width = max_width;
- if (((col < Columns - p_pw || col < Columns - max_width)
+ if (((cursor_col < Columns - p_pw
+ || cursor_col < Columns - max_width)
#ifdef FEAT_RIGHTLEFT
&& !curwin->w_p_rl)
- || (curwin->w_p_rl && (col > p_pw || col > max_width)
+ || (curwin->w_p_rl
+ && (cursor_col > p_pw || cursor_col > max_width)
#endif
))
{
- /* align pum column with "col" */
- pum_col = col;
+ /* align pum with "cursor_col" */
+ pum_col = cursor_col;
/* start with the maximum space available */
#ifdef FEAT_RIGHTLEFT
@@ -237,33 +240,36 @@ pum_display(
if (pum_width > max_width + pum_kind_width + pum_extra_width + 1
&& pum_width > p_pw)
{
- /* the width is too much, make it narrower */
+ /* the width is more than needed for the items, make it
+ * narrower */
pum_width = max_width + pum_kind_width + pum_extra_width + 1;
if (pum_width < p_pw)
pum_width = p_pw;
}
- else if (((col > p_pw || col > max_width)
+ else if (((cursor_col > p_pw || cursor_col > max_width)
#ifdef FEAT_RIGHTLEFT
&& !curwin->w_p_rl)
- || (curwin->w_p_rl && (col < Columns - p_pw
- || col < Columns - max_width)
+ || (curwin->w_p_rl && (cursor_col < Columns - p_pw
+ || cursor_col < Columns - max_width)
#endif
))
{
- /* align right pum edge with "col" */
+ /* align pum edge with "cursor_col" */
#ifdef FEAT_RIGHTLEFT
if (curwin->w_p_rl
&& W_ENDCOL(curwin) < max_width + pum_scrollbar + 1)
{
- pum_col = col + max_width + pum_scrollbar + 1;
+ pum_col = cursor_col + max_width + pum_scrollbar + 1;
if (pum_col >= Columns)
pum_col = Columns - 1;
}
else if (!curwin->w_p_rl)
#endif
{
- if (curwin->w_wincol > Columns - max_width - pum_scrollbar)
+ if (curwin->w_wincol > Columns - max_width - pum_scrollbar
+ && max_width <= p_pw)
{
+ /* use full width to end of the screen */
pum_col = Columns - max_width - pum_scrollbar;
if (pum_col < 0)
pum_col = 0;