]> granicus.if.org Git - vim/commitdiff
patch 8.1.1399: popup windows not adjusted when switching tabs v8.1.1399
authorBram Moolenaar <Bram@vim.org>
Sun, 26 May 2019 12:11:23 +0000 (14:11 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 26 May 2019 12:11:23 +0000 (14:11 +0200)
Problem:    Popup windows not adjusted when switching tabs.
Solution:   Save and restore first_tab_popupwin. Fix closing a tabpage.

src/popupwin.c
src/proto/popupwin.pro
src/testdir/dumps/Test_popupwin_02.dump [new file with mode: 0644]
src/testdir/dumps/Test_popupwin_03.dump [new file with mode: 0644]
src/testdir/dumps/Test_popupwin_04.dump [new file with mode: 0644]
src/testdir/test_popupwin.vim
src/version.c
src/window.c

index f7a8921df4df2ec8253088e0cb16f91d24faef31..294f3b1d6a967f2c32a30101b22811602030bbfe 100644 (file)
@@ -177,40 +177,59 @@ f_popup_close(typval_T *argvars, typval_T *rettv UNUSED)
     popup_close(nr);
 }
 
+/*
+ * Close a popup window by Window-id.
+ */
     void
-popup_close(int nr)
+popup_close(int id)
 {
     win_T      *wp;
+    tabpage_T  *tp;
     win_T      *prev = NULL;
 
+    // go through global popups
     for (wp = first_popupwin; wp != NULL; prev = wp, wp = wp->w_next)
-       if (wp->w_id == nr)
+       if (wp->w_id == id)
        {
            if (prev == NULL)
                first_popupwin = wp->w_next;
            else
                prev->w_next = wp->w_next;
-           break;
+           win_free_popup(wp);
+           redraw_all_later(NOT_VALID);
+           return;
        }
 
-    if (wp == NULL)
-    {
-       prev = NULL;
-       for (wp = first_tab_popupwin; wp != NULL; prev = wp, wp = wp->w_next)
-           if (wp->w_id == nr)
-           {
-               if (prev == NULL)
-                   first_tab_popupwin = wp->w_next;
-               else
-                   prev->w_next = wp->w_next;
-               break;
-           }
-    }
-    if (wp != NULL)
-    {
-       win_free_popup(wp);
-       redraw_all_later(NOT_VALID);
-    }
+    // go through tab-local popups
+    FOR_ALL_TABPAGES(tp)
+       popup_close_tabpage(tp, id);
+}
+
+/*
+ * Close a popup window with Window-id "id" in tabpage "tp".
+ */
+    void
+popup_close_tabpage(tabpage_T *tp, int id)
+{
+    win_T      *wp;
+    win_T      **root;
+    win_T      *prev = NULL;
+
+    if (tp == curtab)
+       root = &first_tab_popupwin;
+    else
+       root = &tp->tp_first_popupwin;
+    for (wp = *root; wp != NULL; prev = wp, wp = wp->w_next)
+       if (wp->w_id == id)
+       {
+           if (prev == NULL)
+               *root = wp->w_next;
+           else
+               prev->w_next = wp->w_next;
+           win_free_popup(wp);
+           redraw_all_later(NOT_VALID);
+           return;
+       }
 }
 
     void
index a3d78b8c6c62aa6f506b68f67def33a609741b8d..172c0794d22e129b262c5a34312164413a8e0c60 100644 (file)
@@ -1,7 +1,8 @@
 /* popupwin.c */
 void f_popup_create(typval_T *argvars, typval_T *rettv);
 void f_popup_close(typval_T *argvars, typval_T *rettv);
-void popup_close(int nr);
+void popup_close(int id);
+void popup_close_tabpage(tabpage_T *tp, int id);
 void close_all_popups(void);
 void ex_popupclear(exarg_T *eap);
 /* vim: set ft=c : */
diff --git a/src/testdir/dumps/Test_popupwin_02.dump b/src/testdir/dumps/Test_popupwin_02.dump
new file mode 100644 (file)
index 0000000..c2aa7a2
--- /dev/null
@@ -0,0 +1,10 @@
+| +8#0000001#e0e0e08|+| |[|N|o| |N|a|m|e|]| | +2#0000000#ffffff0|[|N|o| |N|a|m|e|]| | +1&&@49|X+8#0000001#e0e0e08
+> +0#0000000#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @6|o+0#0000001#ffd7ff255|t|h|e|r| |t|a|b| @10| +0#4040ff13#ffffff0@46
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|:+0#0000000&|c|a|l@1| |p|o|p|u|p|_|c|r|e|a|t|e|(|'|o|t|h|e|r| |t|a|b|'|,| |{|'|l|i|n|e|'|:| |4|,| |'|c|o|l|'|:| |9|}|)| @2|0|,|0|-|1| @8|A|l@1| 
diff --git a/src/testdir/dumps/Test_popupwin_03.dump b/src/testdir/dumps/Test_popupwin_03.dump
new file mode 100644 (file)
index 0000000..7436a01
--- /dev/null
@@ -0,0 +1,10 @@
+| +2&#ffffff0|+| |[|N|o| |N|a|m|e|]| | +8#0000001#e0e0e08|[|N|o| |N|a|m|e|]| | +1#0000000#ffffff0@49|X+8#0000001#e0e0e08
+>1+0#0000000#ffffff0| @73
+|2| @8|h+0&#5fd7ff255|e|l@1|o| |t|h|e|r|e| @8|r+0#0000001#ffd7ff255| |o|n|e| @8| +0#0000000#ffffff0@30
+|3| @22|a+0#0000001#ffd7ff255|n|o|t|h|e|r| |t|w|o| @8| +0#0000000#ffffff0@30
+|4| @22|a+0#0000001#ffd7ff255|n|o|t|h|e|r| |t|h|r|e@1| @6| +0#0000000#ffffff0@30
+|5| @73
+|6| @73
+|7| @73
+|8| @73
+|:|c|a|l@1| |p|o|p|u|p|_|c|r|e|a|t|e|(|'|o|t|h|e|r| |t|a|b|'|,| |{|'|l|i|n|e|'|:| |4|,| |'|c|o| @9|1|,|1| @10|T|o|p| 
diff --git a/src/testdir/dumps/Test_popupwin_04.dump b/src/testdir/dumps/Test_popupwin_04.dump
new file mode 100644 (file)
index 0000000..a642455
--- /dev/null
@@ -0,0 +1,10 @@
+> +0&#ffffff0@74
+|~+0#4040ff13&| @73
+|~| @73
+|~| @6|o+0#0000001#ffd7ff255|t|h|e|r| |t|a|b| @10| +0#4040ff13#ffffff0@46
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|:+0#0000000&|q|u|i|t|!| @50|0|,|0|-|1| @8|A|l@1| 
index 7bae0b5b85308be6b6a7176f0c698b889cb8d793..e79c03d201c7f999098e2ff4527e205ec40174ef 100644 (file)
@@ -20,6 +20,19 @@ func Test_simple_popup()
   let buf = RunVimInTerminal('-S XtestPopup', {'rows': 10})
   call VerifyScreenDump(buf, 'Test_popupwin_01', {})
 
+  " Add a tabpage
+  call term_sendkeys(buf, ":tabnew\<CR>")
+  call term_sendkeys(buf, ":call popup_create('other tab', {'line': 4, 'col': 9})\<CR>")
+  call VerifyScreenDump(buf, 'Test_popupwin_02', {})
+
+  " switch back to first tabpage
+  call term_sendkeys(buf, "gt")
+  call VerifyScreenDump(buf, 'Test_popupwin_03', {})
+
+  " close that tabpage
+  call term_sendkeys(buf, ":quit!\<CR>")
+  call VerifyScreenDump(buf, 'Test_popupwin_04', {})
+
   " clean up
   call StopVimInTerminal(buf)
   call delete('XtestPopup')
index 8cfb965c3d0d49cb39dbdd30ad59847e16af5963..78a932e1686db664764f4a77adbeaf05254a09d6 100644 (file)
@@ -767,6 +767,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1399,
 /**/
     1398,
 /**/
index 4946a3ad36879cb2ee7164eeae0a8550bec04d55..ffff75647eb9765c4a2047bea022907990c8975f 100644 (file)
@@ -3670,8 +3670,17 @@ free_tabpage(tabpage_T *tp)
     diff_clear(tp);
 # endif
 # ifdef FEAT_TEXT_PROP
-    while (tp->tp_first_popupwin != NULL)
-       popup_close(tp->tp_first_popupwin->w_id);
+    {
+       win_T *wp;
+
+       for (;;)
+       {
+           wp = tp == curtab ? first_tab_popupwin : tp->tp_first_popupwin;
+           if (wp == NULL)
+               break;
+           popup_close_tabpage(tp, wp->w_id);
+       }
+    }
 #endif
     for (idx = 0; idx < SNAP_COUNT; ++idx)
        clear_snapshot(tp, idx);
@@ -3964,6 +3973,10 @@ leave_tabpage(
     tp->tp_prevwin = prevwin;
     tp->tp_firstwin = firstwin;
     tp->tp_lastwin = lastwin;
+#ifdef FEAT_TEXT_PROP
+    tp->tp_first_popupwin = first_tab_popupwin;
+    first_tab_popupwin = NULL;
+#endif
     tp->tp_old_Rows = Rows;
     tp->tp_old_Columns = Columns;
     firstwin = NULL;
@@ -3991,6 +4004,9 @@ enter_tabpage(
     firstwin = tp->tp_firstwin;
     lastwin = tp->tp_lastwin;
     topframe = tp->tp_topframe;
+#ifdef FEAT_TEXT_PROP
+    first_tab_popupwin = tp->tp_first_popupwin;
+#endif
 
     /* We would like doing the TabEnter event first, but we don't have a
      * valid current window yet, which may break some commands.
@@ -6497,9 +6513,15 @@ switch_win(
        {
            curtab->tp_firstwin = firstwin;
            curtab->tp_lastwin = lastwin;
+#ifdef FEAT_TEXT_PROP
+           curtab->tp_first_popupwin = first_tab_popupwin ;
+#endif
            curtab = tp;
            firstwin = curtab->tp_firstwin;
            lastwin = curtab->tp_lastwin;
+#ifdef FEAT_TEXT_PROP
+           first_tab_popupwin = curtab->tp_first_popupwin;
+#endif
        }
        else
            goto_tabpage_tp(tp, FALSE, FALSE);
@@ -6528,9 +6550,15 @@ restore_win(
        {
            curtab->tp_firstwin = firstwin;
            curtab->tp_lastwin = lastwin;
+#ifdef FEAT_TEXT_PROP
+           curtab->tp_first_popupwin = first_tab_popupwin ;
+#endif
            curtab = save_curtab;
            firstwin = curtab->tp_firstwin;
            lastwin = curtab->tp_lastwin;
+#ifdef FEAT_TEXT_PROP
+           first_tab_popupwin = curtab->tp_first_popupwin;
+#endif
        }
        else
            goto_tabpage_tp(save_curtab, FALSE, FALSE);