comparison 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
comparison
equal deleted inserted replaced
18395:dbfbbb32cf07 18396:ba5d8c5d77d7
620 screen_zindex = 0; 620 screen_zindex = 0;
621 #endif 621 #endif
622 } 622 }
623 623
624 #if defined(FEAT_TEXT_PROP) && defined(FEAT_QUICKFIX) 624 #if defined(FEAT_TEXT_PROP) && defined(FEAT_QUICKFIX)
625 static void 625 /*
626 pum_position_info_popup(void) 626 * Position the info popup relative to the popup menu item.
627 */
628 void
629 pum_position_info_popup(win_T *wp)
627 { 630 {
628 int col = pum_col + pum_width + 1; 631 int col = pum_col + pum_width + 1;
629 int row = pum_row; 632 int row = pum_row;
630 int botpos = POPPOS_BOTLEFT; 633 int botpos = POPPOS_BOTLEFT;
631 634
632 curwin->w_popup_pos = POPPOS_TOPLEFT; 635 wp->w_popup_pos = POPPOS_TOPLEFT;
633 if (Columns - col < 20 && Columns - col < pum_col) 636 if (Columns - col < 20 && Columns - col < pum_col)
634 { 637 {
635 col = pum_col - 1; 638 col = pum_col - 1;
636 curwin->w_popup_pos = POPPOS_TOPRIGHT; 639 wp->w_popup_pos = POPPOS_TOPRIGHT;
637 botpos = POPPOS_BOTRIGHT; 640 botpos = POPPOS_BOTRIGHT;
638 curwin->w_maxwidth = pum_col - 1; 641 wp->w_maxwidth = pum_col - 1;
639 } 642 }
640 else 643 else
641 curwin->w_maxwidth = Columns - col + 1; 644 wp->w_maxwidth = Columns - col + 1;
642 curwin->w_maxwidth -= popup_extra_width(curwin); 645 wp->w_maxwidth -= popup_extra_width(wp);
643 646
644 row -= popup_top_extra(curwin); 647 row -= popup_top_extra(wp);
645 if (curwin->w_popup_flags & POPF_INFO_MENU) 648 if (wp->w_popup_flags & POPF_INFO_MENU)
646 { 649 {
647 if (pum_row < pum_win_row) 650 if (pum_row < pum_win_row)
648 { 651 {
649 // menu above cursor line, align with bottom 652 // menu above cursor line, align with bottom
650 row += pum_height; 653 row += pum_height;
651 curwin->w_popup_pos = botpos; 654 wp->w_popup_pos = botpos;
652 } 655 }
653 else 656 else
654 // menu below cursor line, align with top 657 // menu below cursor line, align with top
655 row += 1; 658 row += 1;
656 } 659 }
657 else 660 else
658 // align with the selected item 661 // align with the selected item
659 row += pum_selected - pum_first + 1; 662 row += pum_selected - pum_first + 1;
660 663
661 popup_set_wantpos_rowcol(curwin, row, col); 664 popup_set_wantpos_rowcol(wp, row, col);
662 } 665 }
663 #endif 666 #endif
664 667
665 /* 668 /*
666 * Set the index of the currently selected item. The menu will scroll when 669 * Set the index of the currently selected item. The menu will scroll when
754 { 757 {
755 win_T *curwin_save = curwin; 758 win_T *curwin_save = curwin;
756 tabpage_T *curtab_save = curtab; 759 tabpage_T *curtab_save = curtab;
757 int res = OK; 760 int res = OK;
758 # ifdef FEAT_TEXT_PROP 761 # ifdef FEAT_TEXT_PROP
759 int use_popup = strstr((char *)p_cot, "popup") != NULL; 762 use_popup_T use_popup;
760 # else 763 # else
761 # define use_popup 0 764 # define use_popup POPUP_NONE
762 # endif 765 # endif
763 # ifdef FEAT_TEXT_PROP 766 # ifdef FEAT_TEXT_PROP
764 has_info = TRUE; 767 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;
765 # endif 774 # endif
766 // Open a preview window. 3 lines by default. Prefer 775 // Open a preview window and set "curwin" to it.
767 // 'previewheight' if set and smaller. 776 // 3 lines by default, prefer 'previewheight' if set and smaller.
768 g_do_tagpreview = 3; 777 g_do_tagpreview = 3;
769 if (p_pvh > 0 && p_pvh < g_do_tagpreview) 778 if (p_pvh > 0 && p_pvh < g_do_tagpreview)
770 g_do_tagpreview = p_pvh; 779 g_do_tagpreview = p_pvh;
771 ++RedrawingDisabled; 780 ++RedrawingDisabled;
772 // Prevent undo sync here, if an autocommand syncs undo weird 781 // Prevent undo sync here, if an autocommand syncs undo weird
836 // delete the empty last line 845 // delete the empty last line
837 ml_delete(curbuf->b_ml.ml_line_count, FALSE); 846 ml_delete(curbuf->b_ml.ml_line_count, FALSE);
838 847
839 /* Increase the height of the preview window to show the 848 /* Increase the height of the preview window to show the
840 * text, but no more than 'previewheight' lines. */ 849 * text, but no more than 'previewheight' lines. */
841 if (repeat == 0 && !use_popup) 850 if (repeat == 0 && use_popup == USEPOPUP_NONE)
842 { 851 {
843 if (lnum > p_pvh) 852 if (lnum > p_pvh)
844 lnum = p_pvh; 853 lnum = p_pvh;
845 if (curwin->w_height < lnum) 854 if (curwin->w_height < lnum)
846 { 855 {
861 else if (curwin->w_topline > curbuf->b_ml.ml_line_count) 870 else if (curwin->w_topline > curbuf->b_ml.ml_line_count)
862 curwin->w_topline = curbuf->b_ml.ml_line_count; 871 curwin->w_topline = curbuf->b_ml.ml_line_count;
863 curwin->w_cursor.lnum = curwin->w_topline; 872 curwin->w_cursor.lnum = curwin->w_topline;
864 curwin->w_cursor.col = 0; 873 curwin->w_cursor.col = 0;
865 # ifdef FEAT_TEXT_PROP 874 # ifdef FEAT_TEXT_PROP
866 if (use_popup) 875 if (use_popup != USEPOPUP_NONE)
867 { 876 {
868 pum_position_info_popup(); 877 pum_position_info_popup(curwin);
869 if (win_valid(curwin_save)) 878 if (win_valid(curwin_save))
870 redraw_win_later(curwin_save, SOME_VALID); 879 redraw_win_later(curwin_save, SOME_VALID);
871 } 880 }
872 # endif 881 # endif
873 if ((curwin != curwin_save && win_valid(curwin_save)) 882 if ((curwin != curwin_save && win_valid(curwin_save))
905 update_screen(0); 914 update_screen(0);
906 pum_do_redraw = FALSE; 915 pum_do_redraw = FALSE;
907 916
908 if (!resized && win_valid(curwin_save)) 917 if (!resized && win_valid(curwin_save))
909 { 918 {
919 # ifdef FEAT_TEXT_PROP
920 win_T *wp = curwin;
921 # endif
910 ++no_u_sync; 922 ++no_u_sync;
911 win_enter(curwin_save, TRUE); 923 win_enter(curwin_save, TRUE);
912 --no_u_sync; 924 --no_u_sync;
925 # ifdef FEAT_TEXT_PROP
926 if (use_popup == USEPOPUP_HIDDEN && win_valid(wp))
927 popup_hide(wp);
928 # endif
913 } 929 }
914 930
915 /* May need to update the screen again when there are 931 /* May need to update the screen again when there are
916 * autocommands involved. */ 932 * autocommands involved. */
917 pum_do_redraw = TRUE; 933 pum_do_redraw = TRUE;