diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-05-26 14:11:23 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-05-26 14:11:23 +0200 |
commit | ec58384afa0dc1678afd7b8d19b4645ac2f73f42 (patch) | |
tree | 542962e10b9053a34c1a966e7583709e9d40b960 /src | |
parent | a8c99fb78e9d747c127e8878518d5a43837b022b (diff) | |
download | vim-git-ec58384afa0dc1678afd7b8d19b4645ac2f73f42.tar.gz |
patch 8.1.1399: popup windows not adjusted when switching tabsv8.1.1399
Problem: Popup windows not adjusted when switching tabs.
Solution: Save and restore first_tab_popupwin. Fix closing a tabpage.
Diffstat (limited to 'src')
-rw-r--r-- | src/popupwin.c | 61 | ||||
-rw-r--r-- | src/proto/popupwin.pro | 3 | ||||
-rw-r--r-- | src/testdir/dumps/Test_popupwin_02.dump | 10 | ||||
-rw-r--r-- | src/testdir/dumps/Test_popupwin_03.dump | 10 | ||||
-rw-r--r-- | src/testdir/dumps/Test_popupwin_04.dump | 10 | ||||
-rw-r--r-- | src/testdir/test_popupwin.vim | 13 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/window.c | 32 |
8 files changed, 117 insertions, 24 deletions
diff --git a/src/popupwin.c b/src/popupwin.c index f7a8921df..294f3b1d6 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -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 diff --git a/src/proto/popupwin.pro b/src/proto/popupwin.pro index a3d78b8c6..172c0794d 100644 --- a/src/proto/popupwin.pro +++ b/src/proto/popupwin.pro @@ -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 index 000000000..c2aa7a287 --- /dev/null +++ b/src/testdir/dumps/Test_popupwin_02.dump @@ -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 index 000000000..7436a0176 --- /dev/null +++ b/src/testdir/dumps/Test_popupwin_03.dump @@ -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+0fd7ff255|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 index 000000000..a64245560 --- /dev/null +++ b/src/testdir/dumps/Test_popupwin_04.dump @@ -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| diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim index 7bae0b5b8..e79c03d20 100644 --- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -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') diff --git a/src/version.c b/src/version.c index 8cfb965c3..78a932e16 100644 --- a/src/version.c +++ b/src/version.c @@ -768,6 +768,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1399, +/**/ 1398, /**/ 1397, diff --git a/src/window.c b/src/window.c index 4946a3ad3..ffff75647 100644 --- a/src/window.c +++ b/src/window.c @@ -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); |