0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

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 #4924)
This commit is contained in:
Bram Moolenaar
2019-10-20 18:17:57 +02:00
parent 88d3d09e07
commit dca7abe79c
15 changed files with 195 additions and 28 deletions

View File

@@ -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 UNUSED)
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 UNUSED)
/* 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 UNUSED)
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 UNUSED)
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