Mercurial > vim
diff src/popupwin.c @ 19540:9f07a6c172f2 v8.2.0327
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
patch 8.2.0327: crash when opening and closing two popup terminal windows
Problem: Crash when opening and closing two popup terminal windows.
Solution: Check that prevwin is valid. (closes https://github.com/vim/vim/issues/5707)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 28 Feb 2020 19:15:04 +0100 |
parents | b70fbf3f0e0b |
children | 9e428147e4ee |
line wrap: on
line diff
--- a/src/popupwin.c +++ b/src/popupwin.c @@ -2114,9 +2114,31 @@ popup_close_and_callback(win_T *wp, typv #ifdef FEAT_TERMINAL if (wp == curwin && curbuf->b_term != NULL) { - // Closing popup window with a terminal: put focus back on the previous - // window. - win_enter(prevwin, FALSE); + win_T *owp; + + // Closing popup window with a terminal: put focus back on the first + // that works: + // - another popup window with a terminal + // - the previous window + // - the first one. + for (owp = first_popupwin; owp != NULL; owp = owp->w_next) + if (owp != curwin && owp->w_buffer->b_term != NULL) + break; + if (owp != NULL) + win_enter(owp, FALSE); + else + { + for (owp = curtab->tp_first_popupwin; owp != NULL; + owp = owp->w_next) + if (owp != curwin && owp->w_buffer->b_term != NULL) + break; + if (owp != NULL) + win_enter(owp, FALSE); + else if (win_valid(prevwin)) + win_enter(prevwin, FALSE); + else + win_enter(firstwin, FALSE); + } } #endif