]> granicus.if.org Git - vim/commitdiff
patch 8.1.0057: popup menu displayed wrong when using autocmd v8.1.0057
authorBram Moolenaar <Bram@vim.org>
Sat, 16 Jun 2018 13:32:38 +0000 (15:32 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 16 Jun 2018 13:32:38 +0000 (15:32 +0200)
Problem:    Popup menu displayed wrong when using autocmd.
Solution:   Use aucmd_prepbuf().  Force updating status line if the popup menu
            is going to be redrawn anyway. (Christian Brabandt, closes #3009)

src/edit.c
src/proto/screen.pro
src/screen.c
src/version.c

index 92c9d6ad447e202597c22c542972c81cebd0b145..326a382b5493590c8d0d8b92b13a9de0e0e9dcd0 100644 (file)
@@ -1704,7 +1704,12 @@ ins_redraw(
 #endif
            )
     {
+       aco_save_T      aco;
+
+       // save and restore curwin and curbuf, in case the autocmd changes them
+       aucmd_prepbuf(&aco, curbuf);
        apply_autocmds(EVENT_TEXTCHANGEDI, NULL, NULL, FALSE, curbuf);
+       aucmd_restbuf(&aco);
        curbuf->b_last_changedtick = CHANGEDTICK(curbuf);
     }
 
@@ -1716,7 +1721,12 @@ ins_redraw(
            && curbuf->b_last_changedtick_pum != CHANGEDTICK(curbuf)
            && pum_visible())
     {
+       aco_save_T      aco;
+
+       // save and restore curwin and curbuf, in case the autocmd changes them
+       aucmd_prepbuf(&aco, curbuf);
        apply_autocmds(EVENT_TEXTCHANGEDP, NULL, NULL, FALSE, curbuf);
+       aucmd_restbuf(&aco);
        curbuf->b_last_changedtick_pum = CHANGEDTICK(curbuf);
     }
 #endif
index 5760dae1b3cbe80e620da52ca9831644d79cbc20..2b8a6fd028aec44169034961dc8e7157eb984b66 100644 (file)
@@ -25,7 +25,6 @@ void status_redraw_curbuf(void);
 void redraw_statuslines(void);
 void win_redraw_last_status(frame_T *frp);
 void win_redr_status_matches(expand_T *xp, int num_matches, char_u **matches, int match, int showtail);
-void win_redr_status(win_T *wp);
 int stl_connected(win_T *wp);
 int get_keymap_str(win_T *wp, char_u *fmt, char_u *buf, int len);
 void screen_putchar(int c, int row, int col, int attr);
index f2c58bee78ac15bb67cb70a2349cc98fac130af8..cd293159243a1a7bf4774208167787a1241ed16f 100644 (file)
@@ -125,6 +125,7 @@ static int redrawing_for_callback = 0;
 static schar_T *current_ScreenLine;
 
 static void win_update(win_T *wp);
+static void win_redr_status(win_T *wp, int ignore_pum);
 static void win_draw_end(win_T *wp, int c1, int c2, int row, int endrow, hlf_T hl);
 #ifdef FEAT_FOLDING
 static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T lnum, int row);
@@ -774,7 +775,7 @@ update_screen(int type_arg)
        if (wp->w_redr_status)
        {
            cursor_off();
-           win_redr_status(wp);
+           win_redr_status(wp, TRUE); // any popup menu will be redrawn below
        }
     }
 #if defined(FEAT_SEARCH_EXTRA)
@@ -1030,7 +1031,7 @@ update_debug_sign(buf_T *buf, linenr_T lnum)
        if (wp->w_redr_type != 0)
            win_update(wp);
        if (wp->w_redr_status)
-           win_redr_status(wp);
+           win_redr_status(wp, FALSE);
     }
 
     update_finish();
@@ -1074,7 +1075,7 @@ updateWindow(win_T *wp)
            || *p_stl != NUL || *wp->w_p_stl != NUL
 # endif
            )
-       win_redr_status(wp);
+       win_redr_status(wp, FALSE);
 
     update_finish();
 }
@@ -6535,7 +6536,7 @@ redraw_statuslines(void)
 
     FOR_ALL_WINDOWS(wp)
        if (wp->w_redr_status)
-           win_redr_status(wp);
+           win_redr_status(wp, FALSE);
     if (redraw_tabline)
        draw_tabline();
 }
@@ -6864,9 +6865,11 @@ win_redr_status_matches(
  * Redraw the status line of window wp.
  *
  * If inversion is possible we use it. Else '=' characters are used.
+ * If "ignore_pum" is TRUE, also redraw statusline when the popup menu is
+ * displayed.
  */
-    void
-win_redr_status(win_T *wp)
+    static void
+win_redr_status(win_T *wp, int ignore_pum)
 {
     int                row;
     char_u     *p;
@@ -6890,9 +6893,9 @@ win_redr_status(win_T *wp)
     }
     else if (!redrawing()
 #ifdef FEAT_INS_EXPAND
-           /* don't update status line when popup menu is visible and may be
-            * drawn over it */
-           || pum_visible()
+           // don't update status line when popup menu is visible and may be
+           // drawn over it, unless it will be redrawn later
+           || (!ignore_pum && pum_visible())
 #endif
            )
     {
index bd8efafeb380096ef55d325a304131ba889e256f..f4ecfe7558fc2cc24ec1cdb5208bbbca0d7d612c 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    57,
 /**/
     56,
 /**/