Skip to content

Commit cb03642

Browse files
committed
patch 8.0.0390: when the window scrolls the popup menu may be garbled
Problem: When the window scrolls horizontally when the popup menu is displayed part of it may not be cleared. (Neovim issue #6184) Solution: Remove the menu when the windows scrolled. (closes #1524)
1 parent 5342f00 commit cb03642

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

src/edit.c

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static int ins_compl_pum_key(int c);
186186
static int ins_compl_key2count(int c);
187187
static int ins_compl_use_match(int c);
188188
static int ins_complete(int c, int enable_pum);
189-
static void show_pum(int save_w_wrow);
189+
static void show_pum(int prev_w_wrow, int prev_w_leftcol);
190190
static unsigned quote_meta(char_u *dest, char_u *str, int len);
191191
#endif /* FEAT_INS_EXPAND */
192192

@@ -2818,6 +2818,7 @@ completeopt_was_set(void)
28182818
set_completion(colnr_T startcol, list_T *list)
28192819
{
28202820
int save_w_wrow = curwin->w_wrow;
2821+
int save_w_leftcol = curwin->w_leftcol;
28212822

28222823
/* If already doing completions stop it. */
28232824
if (ctrl_x_mode != 0)
@@ -2858,7 +2859,7 @@ set_completion(colnr_T startcol, list_T *list)
28582859

28592860
/* Lazily show the popup menu, unless we got interrupted. */
28602861
if (!compl_interrupted)
2861-
show_pum(save_w_wrow);
2862+
show_pum(save_w_wrow, save_w_leftcol);
28622863
out_flush();
28632864
}
28642865

@@ -5096,6 +5097,7 @@ ins_complete(int c, int enable_pum)
50965097
colnr_T curs_col; /* cursor column */
50975098
int n;
50985099
int save_w_wrow;
5100+
int save_w_leftcol;
50995101
int insert_match;
51005102
int save_did_ai = did_ai;
51015103

@@ -5539,6 +5541,7 @@ ins_complete(int c, int enable_pum)
55395541
* Find next match (and following matches).
55405542
*/
55415543
save_w_wrow = curwin->w_wrow;
5544+
save_w_leftcol = curwin->w_leftcol;
55425545
n = ins_compl_next(TRUE, ins_compl_key2count(c), insert_match, FALSE);
55435546

55445547
/* may undisplay the popup menu */
@@ -5691,31 +5694,31 @@ ins_complete(int c, int enable_pum)
56915694

56925695
/* Show the popup menu, unless we got interrupted. */
56935696
if (enable_pum && !compl_interrupted)
5694-
{
5695-
show_pum(save_w_wrow);
5696-
}
5697+
show_pum(save_w_wrow, save_w_leftcol);
5698+
56975699
compl_was_interrupted = compl_interrupted;
56985700
compl_interrupted = FALSE;
56995701

57005702
return OK;
57015703
}
57025704

57035705
static void
5704-
show_pum(int save_w_wrow)
5706+
show_pum(int prev_w_wrow, int prev_w_leftcol)
57055707
{
5706-
/* RedrawingDisabled may be set when invoked through complete(). */
5707-
int n = RedrawingDisabled;
5708+
/* RedrawingDisabled may be set when invoked through complete(). */
5709+
int n = RedrawingDisabled;
57085710

5709-
RedrawingDisabled = 0;
5711+
RedrawingDisabled = 0;
57105712

5711-
/* If the cursor moved we need to remove the pum first. */
5712-
setcursor();
5713-
if (save_w_wrow != curwin->w_wrow)
5714-
ins_compl_del_pum();
5713+
/* If the cursor moved or the display scrolled we need to remove the pum
5714+
* first. */
5715+
setcursor();
5716+
if (prev_w_wrow != curwin->w_wrow || prev_w_leftcol != curwin->w_leftcol)
5717+
ins_compl_del_pum();
57155718

5716-
ins_compl_show_pum();
5717-
setcursor();
5718-
RedrawingDisabled = n;
5719+
ins_compl_show_pum();
5720+
setcursor();
5721+
RedrawingDisabled = n;
57195722
}
57205723

57215724
/*

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+
390,
767769
/**/
768770
389,
769771
/**/

0 commit comments

Comments
 (0)