Mirror of the Vim source from https://github.com/vim/vim
修订版 | 9f07a6c172f2a82c5910e7c057038d39a72aff9e (tree) |
---|---|
时间 | 2020-02-29 03:15:04 |
作者 | Bram Moolenaar <Bram@vim....> |
Commiter | Bram Moolenaar |
patch 8.2.0327: crash when opening and closing two popup terminal windows
Commit: https://github.com/vim/vim/commit/80ae880f5fed8022c69d05dd1efee49259929cb5
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Feb 28 19:11:18 2020 +0100
@@ -2114,9 +2114,31 @@ | ||
2114 | 2114 | #ifdef FEAT_TERMINAL |
2115 | 2115 | if (wp == curwin && curbuf->b_term != NULL) |
2116 | 2116 | { |
2117 | - // Closing popup window with a terminal: put focus back on the previous | |
2118 | - // window. | |
2119 | - win_enter(prevwin, FALSE); | |
2117 | + win_T *owp; | |
2118 | + | |
2119 | + // Closing popup window with a terminal: put focus back on the first | |
2120 | + // that works: | |
2121 | + // - another popup window with a terminal | |
2122 | + // - the previous window | |
2123 | + // - the first one. | |
2124 | + for (owp = first_popupwin; owp != NULL; owp = owp->w_next) | |
2125 | + if (owp != curwin && owp->w_buffer->b_term != NULL) | |
2126 | + break; | |
2127 | + if (owp != NULL) | |
2128 | + win_enter(owp, FALSE); | |
2129 | + else | |
2130 | + { | |
2131 | + for (owp = curtab->tp_first_popupwin; owp != NULL; | |
2132 | + owp = owp->w_next) | |
2133 | + if (owp != curwin && owp->w_buffer->b_term != NULL) | |
2134 | + break; | |
2135 | + if (owp != NULL) | |
2136 | + win_enter(owp, FALSE); | |
2137 | + else if (win_valid(prevwin)) | |
2138 | + win_enter(prevwin, FALSE); | |
2139 | + else | |
2140 | + win_enter(firstwin, FALSE); | |
2141 | + } | |
2120 | 2142 | } |
2121 | 2143 | #endif |
2122 | 2144 |
@@ -2391,6 +2391,17 @@ | ||
2391 | 2391 | call delete('XtermPopup') |
2392 | 2392 | endfunc |
2393 | 2393 | |
2394 | +func Test_double_popup_terminal() | |
2395 | + let buf1 = term_start(&shell, #{hidden: 1}) | |
2396 | + let win1 = popup_create(buf1, {}) | |
2397 | + let buf2 = term_start(&shell, #{hidden: 1}) | |
2398 | + let win2 = popup_create(buf2, {}) | |
2399 | + call popup_close(win1) | |
2400 | + call popup_close(win2) | |
2401 | + exe buf1 .. 'bwipe!' | |
2402 | + exe buf2 .. 'bwipe!' | |
2403 | +endfunc | |
2404 | + | |
2394 | 2405 | func Test_issue_5607() |
2395 | 2406 | let wincount = winnr('$') |
2396 | 2407 | exe 'terminal' &shell &shellcmdflag 'exit' |
@@ -739,6 +739,8 @@ | ||
739 | 739 | static int included_patches[] = |
740 | 740 | { /* Add new patch number below this line */ |
741 | 741 | /**/ |
742 | + 327, | |
743 | +/**/ | |
742 | 744 | 326, |
743 | 745 | /**/ |
744 | 746 | 325, |