diff src/popupmenu.c @ 18396:ba5d8c5d77d7 v8.1.2192

patch 8.1.2192: cannot easily fill the info popup asynchronously Commit: https://github.com/vim/vim/commit/dca7abe79cc4f0933473c3e4bcc75b46cc2c48fd Author: Bram Moolenaar <Bram@vim.org> Date: Sun Oct 20 18:17:57 2019 +0200 patch 8.1.2192: cannot easily fill the info popup asynchronously Problem: Cannot easily fill the info popup asynchronously. Solution: Add the "popuphidden" value to 'completeopt'. (closes https://github.com/vim/vim/issues/4924)
author Bram Moolenaar <Bram@vim.org>
date Sun, 20 Oct 2019 18:30:04 +0200
parents c8a53c0daeed
children 81272918c0ea
line wrap: on
line diff
--- a/src/popupmenu.c
+++ b/src/popupmenu.c
@@ -622,33 +622,36 @@ pum_redraw(void)
 }
 
 #if defined(FEAT_TEXT_PROP) && defined(FEAT_QUICKFIX)
-    static void
-pum_position_info_popup(void)
+/*
+ * Position the info popup relative to the popup menu item.
+ */
+    void
+pum_position_info_popup(win_T *wp)
 {
     int col = pum_col + pum_width + 1;
     int row = pum_row;
     int botpos = POPPOS_BOTLEFT;
 
-    curwin->w_popup_pos = POPPOS_TOPLEFT;
+    wp->w_popup_pos = POPPOS_TOPLEFT;
     if (Columns - col < 20 && Columns - col < pum_col)
     {
 	col = pum_col - 1;
-	curwin->w_popup_pos = POPPOS_TOPRIGHT;
+	wp->w_popup_pos = POPPOS_TOPRIGHT;
 	botpos = POPPOS_BOTRIGHT;
-	curwin->w_maxwidth = pum_col - 1;
+	wp->w_maxwidth = pum_col - 1;
     }
     else
-	curwin->w_maxwidth = Columns - col + 1;
-    curwin->w_maxwidth -= popup_extra_width(curwin);
+	wp->w_maxwidth = Columns - col + 1;
+    wp->w_maxwidth -= popup_extra_width(wp);
 
-    row -= popup_top_extra(curwin);
-    if (curwin->w_popup_flags & POPF_INFO_MENU)
+    row -= popup_top_extra(wp);
+    if (wp->w_popup_flags & POPF_INFO_MENU)
     {
 	if (pum_row < pum_win_row)
 	{
 	    // menu above cursor line, align with bottom
 	    row += pum_height;
-	    curwin->w_popup_pos = botpos;
+	    wp->w_popup_pos = botpos;
 	}
 	else
 	    // menu below cursor line, align with top
@@ -658,7 +661,7 @@ pum_position_info_popup(void)
 	// align with the selected item
 	row += pum_selected - pum_first + 1;
 
-    popup_set_wantpos_rowcol(curwin, row, col);
+    popup_set_wantpos_rowcol(wp, row, col);
 }
 #endif
 
@@ -756,15 +759,21 @@ pum_set_selected(int n, int repeat UNUSE
 	    tabpage_T   *curtab_save = curtab;
 	    int		res = OK;
 # ifdef FEAT_TEXT_PROP
-	    int		use_popup = strstr((char *)p_cot, "popup") != NULL;
+	    use_popup_T	use_popup;
 # else
-#  define use_popup 0
+#  define use_popup POPUP_NONE
 # endif
 # ifdef FEAT_TEXT_PROP
 	    has_info = TRUE;
+	    if (strstr((char *)p_cot, "popuphidden") != NULL)
+		use_popup = USEPOPUP_HIDDEN;
+	    else if (strstr((char *)p_cot, "popup") != NULL)
+		use_popup = USEPOPUP_NORMAL;
+	    else
+		use_popup = USEPOPUP_NONE;
 # endif
-	    // Open a preview window.  3 lines by default.  Prefer
-	    // 'previewheight' if set and smaller.
+	    // Open a preview window and set "curwin" to it.
+	    // 3 lines by default, prefer 'previewheight' if set and smaller.
 	    g_do_tagpreview = 3;
 	    if (p_pvh > 0 && p_pvh < g_do_tagpreview)
 		g_do_tagpreview = p_pvh;
@@ -838,7 +847,7 @@ pum_set_selected(int n, int repeat UNUSE
 
 		    /* Increase the height of the preview window to show the
 		     * text, but no more than 'previewheight' lines. */
-		    if (repeat == 0 && !use_popup)
+		    if (repeat == 0 && use_popup == USEPOPUP_NONE)
 		    {
 			if (lnum > p_pvh)
 			    lnum = p_pvh;
@@ -863,9 +872,9 @@ pum_set_selected(int n, int repeat UNUSE
 		    curwin->w_cursor.lnum = curwin->w_topline;
 		    curwin->w_cursor.col = 0;
 # ifdef FEAT_TEXT_PROP
-		    if (use_popup)
+		    if (use_popup != USEPOPUP_NONE)
 		    {
-			pum_position_info_popup();
+			pum_position_info_popup(curwin);
 			if (win_valid(curwin_save))
 			    redraw_win_later(curwin_save, SOME_VALID);
 		    }
@@ -907,9 +916,16 @@ pum_set_selected(int n, int repeat UNUSE
 
 			if (!resized && win_valid(curwin_save))
 			{
+# ifdef FEAT_TEXT_PROP
+			    win_T *wp = curwin;
+# endif
 			    ++no_u_sync;
 			    win_enter(curwin_save, TRUE);
 			    --no_u_sync;
+# ifdef FEAT_TEXT_PROP
+			    if (use_popup == USEPOPUP_HIDDEN && win_valid(wp))
+				popup_hide(wp);
+# endif
 			}
 
 			/* May need to update the screen again when there are