• R/O
  • SSH

vim: 提交

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

修订版9f07a6c172f2a82c5910e7c057038d39a72aff9e (tree)
时间2020-02-29 03:15:04
作者Bram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Log Message

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)

更改概述

差异

diff -r a31e293bd464 -r 9f07a6c172f2 src/popupwin.c
--- a/src/popupwin.c Thu Feb 27 22:00:04 2020 +0100
+++ b/src/popupwin.c Fri Feb 28 19:15:04 2020 +0100
@@ -2114,9 +2114,31 @@
21142114 #ifdef FEAT_TERMINAL
21152115 if (wp == curwin && curbuf->b_term != NULL)
21162116 {
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+ }
21202142 }
21212143 #endif
21222144
diff -r a31e293bd464 -r 9f07a6c172f2 src/testdir/test_terminal.vim
--- a/src/testdir/test_terminal.vim Thu Feb 27 22:00:04 2020 +0100
+++ b/src/testdir/test_terminal.vim Fri Feb 28 19:15:04 2020 +0100
@@ -2391,6 +2391,17 @@
23912391 call delete('XtermPopup')
23922392 endfunc
23932393
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+
23942405 func Test_issue_5607()
23952406 let wincount = winnr('$')
23962407 exe 'terminal' &shell &shellcmdflag 'exit'
diff -r a31e293bd464 -r 9f07a6c172f2 src/version.c
--- a/src/version.c Thu Feb 27 22:00:04 2020 +0100
+++ b/src/version.c Fri Feb 28 19:15:04 2020 +0100
@@ -739,6 +739,8 @@
739739 static int included_patches[] =
740740 { /* Add new patch number below this line */
741741 /**/
742+ 327,
743+/**/
742744 326,
743745 /**/
744746 325,
Show on old repository browser