Skip to content

Commit 91e44a3

Browse files
committed
patch 8.0.0058
Problem: Positioning of the popup menu is not good. Solution: Position it better. (Hirohito Higashi)
1 parent 9376f5f commit 91e44a3

2 files changed

Lines changed: 24 additions & 24 deletions

File tree

src/popupmnu.c

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,21 @@ pum_display(
5454
int kind_width;
5555
int extra_width;
5656
int i;
57-
int top_clear;
5857
int row;
5958
int context_lines;
6059
int col;
61-
int above_row = cmdline_row;
60+
int above_row;
61+
int below_row;
6262
int redo_count = 0;
63+
win_T *pvwin;
6364

6465
redo:
6566
def_width = PUM_DEF_WIDTH;
6667
max_width = 0;
6768
kind_width = 0;
6869
extra_width = 0;
70+
above_row = 0;
71+
below_row = cmdline_row;
6972

7073
/* Pretend the pum is already there to avoid that must_redraw is set when
7174
* 'cuc' is on. */
@@ -76,18 +79,16 @@ pum_display(
7679
row = curwin->w_wrow + W_WINROW(curwin);
7780

7881
#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
79-
if (firstwin->w_p_pvw)
80-
top_clear = firstwin->w_height;
81-
else
82-
#endif
83-
top_clear = 0;
84-
85-
#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
86-
/* When the preview window is at the bottom stop just above it. Also
87-
* avoid drawing over the status line so that it's clear there is a window
88-
* boundary. */
89-
if (lastwin->w_p_pvw)
90-
above_row -= lastwin->w_height + lastwin->w_status_height + 1;
82+
FOR_ALL_WINDOWS(pvwin)
83+
if (pvwin->w_p_pvw)
84+
break;
85+
if (pvwin != NULL)
86+
{
87+
if (W_WINROW(pvwin) < W_WINROW(curwin))
88+
above_row = W_WINROW(pvwin) + pvwin->w_height;
89+
else if (W_WINROW(pvwin) > W_WINROW(curwin) + curwin->w_height)
90+
below_row = W_WINROW(pvwin);
91+
}
9192
#endif
9293

9394
/*
@@ -102,8 +103,7 @@ pum_display(
102103

103104
/* Put the pum below "row" if possible. If there are few lines decide on
104105
* where there is more room. */
105-
if (row + 2 >= above_row - pum_height
106-
&& row > (above_row - top_clear) / 2)
106+
if (row - above_row >= below_row - row)
107107
{
108108
/* pum above "row" */
109109

@@ -141,8 +141,8 @@ pum_display(
141141
+ curwin->w_cline_height - curwin->w_wrow;
142142

143143
pum_row = row + context_lines;
144-
if (size > above_row - pum_row)
145-
pum_height = above_row - pum_row;
144+
if (size > below_row - pum_row)
145+
pum_height = below_row - pum_row;
146146
else
147147
pum_height = size;
148148
if (p_ph > 0 && pum_height > p_ph)
@@ -154,13 +154,11 @@ pum_display(
154154
return;
155155

156156
#if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX)
157-
/* If there is a preview window at the top avoid drawing over it. */
158-
if (firstwin->w_p_pvw
159-
&& pum_row < firstwin->w_height
160-
&& pum_height > firstwin->w_height + 4)
157+
/* If there is a preview window at the above avoid drawing over it. */
158+
if (pvwin != NULL && pum_row < above_row && pum_height > above_row)
161159
{
162-
pum_row += firstwin->w_height;
163-
pum_height -= firstwin->w_height;
160+
pum_row += above_row;
161+
pum_height -= above_row;
164162
}
165163
#endif
166164

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
58,
767769
/**/
768770
57,
769771
/**/

0 commit comments

Comments
 (0)