@@ -186,7 +186,7 @@ static int ins_compl_pum_key(int c);
186186static int ins_compl_key2count (int c );
187187static int ins_compl_use_match (int c );
188188static 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 );
190190static 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)
28182818set_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/*
0 commit comments