@@ -622,33 +622,36 @@ pum_redraw(void)
622622}
623623
624624#if defined(FEAT_TEXT_PROP ) && defined(FEAT_QUICKFIX )
625- static void
626- pum_position_info_popup (void )
625+ /*
626+ * Position the info popup relative to the popup menu item.
627+ */
628+ void
629+ pum_position_info_popup (win_T * wp )
627630{
628631 int col = pum_col + pum_width + 1 ;
629632 int row = pum_row ;
630633 int botpos = POPPOS_BOTLEFT ;
631634
632- curwin -> w_popup_pos = POPPOS_TOPLEFT ;
635+ wp -> w_popup_pos = POPPOS_TOPLEFT ;
633636 if (Columns - col < 20 && Columns - col < pum_col )
634637 {
635638 col = pum_col - 1 ;
636- curwin -> w_popup_pos = POPPOS_TOPRIGHT ;
639+ wp -> w_popup_pos = POPPOS_TOPRIGHT ;
637640 botpos = POPPOS_BOTRIGHT ;
638- curwin -> w_maxwidth = pum_col - 1 ;
641+ wp -> w_maxwidth = pum_col - 1 ;
639642 }
640643 else
641- curwin -> w_maxwidth = Columns - col + 1 ;
642- curwin -> w_maxwidth -= popup_extra_width (curwin );
644+ wp -> w_maxwidth = Columns - col + 1 ;
645+ wp -> w_maxwidth -= popup_extra_width (wp );
643646
644- row -= popup_top_extra (curwin );
645- if (curwin -> w_popup_flags & POPF_INFO_MENU )
647+ row -= popup_top_extra (wp );
648+ if (wp -> w_popup_flags & POPF_INFO_MENU )
646649 {
647650 if (pum_row < pum_win_row )
648651 {
649652 // menu above cursor line, align with bottom
650653 row += pum_height ;
651- curwin -> w_popup_pos = botpos ;
654+ wp -> w_popup_pos = botpos ;
652655 }
653656 else
654657 // menu below cursor line, align with top
@@ -658,7 +661,7 @@ pum_position_info_popup(void)
658661 // align with the selected item
659662 row += pum_selected - pum_first + 1 ;
660663
661- popup_set_wantpos_rowcol (curwin , row , col );
664+ popup_set_wantpos_rowcol (wp , row , col );
662665}
663666#endif
664667
@@ -756,15 +759,21 @@ pum_set_selected(int n, int repeat UNUSED)
756759 tabpage_T * curtab_save = curtab ;
757760 int res = OK ;
758761# ifdef FEAT_TEXT_PROP
759- int use_popup = strstr (( char * ) p_cot , "popup" ) != NULL ;
762+ use_popup_T use_popup ;
760763# else
761- # define use_popup 0
764+ # define use_popup POPUP_NONE
762765# endif
763766# ifdef FEAT_TEXT_PROP
764767 has_info = TRUE;
768+ if (strstr ((char * )p_cot , "popuphidden" ) != NULL )
769+ use_popup = USEPOPUP_HIDDEN ;
770+ else if (strstr ((char * )p_cot , "popup" ) != NULL )
771+ use_popup = USEPOPUP_NORMAL ;
772+ else
773+ use_popup = USEPOPUP_NONE ;
765774# endif
766- // Open a preview window. 3 lines by default. Prefer
767- // 'previewheight' if set and smaller.
775+ // Open a preview window and set "curwin" to it.
776+ // 3 lines by default, prefer 'previewheight' if set and smaller.
768777 g_do_tagpreview = 3 ;
769778 if (p_pvh > 0 && p_pvh < g_do_tagpreview )
770779 g_do_tagpreview = p_pvh ;
@@ -838,7 +847,7 @@ pum_set_selected(int n, int repeat UNUSED)
838847
839848 /* Increase the height of the preview window to show the
840849 * text, but no more than 'previewheight' lines. */
841- if (repeat == 0 && ! use_popup )
850+ if (repeat == 0 && use_popup == USEPOPUP_NONE )
842851 {
843852 if (lnum > p_pvh )
844853 lnum = p_pvh ;
@@ -863,9 +872,9 @@ pum_set_selected(int n, int repeat UNUSED)
863872 curwin -> w_cursor .lnum = curwin -> w_topline ;
864873 curwin -> w_cursor .col = 0 ;
865874# ifdef FEAT_TEXT_PROP
866- if (use_popup )
875+ if (use_popup != USEPOPUP_NONE )
867876 {
868- pum_position_info_popup ();
877+ pum_position_info_popup (curwin );
869878 if (win_valid (curwin_save ))
870879 redraw_win_later (curwin_save , SOME_VALID );
871880 }
@@ -907,9 +916,16 @@ pum_set_selected(int n, int repeat UNUSED)
907916
908917 if (!resized && win_valid (curwin_save ))
909918 {
919+ # ifdef FEAT_TEXT_PROP
920+ win_T * wp = curwin ;
921+ # endif
910922 ++ no_u_sync ;
911923 win_enter (curwin_save , TRUE);
912924 -- no_u_sync ;
925+ # ifdef FEAT_TEXT_PROP
926+ if (use_popup == USEPOPUP_HIDDEN && win_valid (wp ))
927+ popup_hide (wp );
928+ # endif
913929 }
914930
915931 /* May need to update the screen again when there are
0 commit comments