Skip to content

Commit eea1699

Browse files
committed
patch 8.1.1433: win_execute() may leave popup window focused
Problem: Win_execute() may leave popup window focused, eventually leading to a crash. (Bjorn Linse) Solution: When previous window was closed, go to the first window.
1 parent ccd6e34 commit eea1699

3 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/testdir/test_popupwin.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ func Test_popup_with_syntax_setbufvar()
105105
call delete('XtestPopup')
106106
endfunc
107107

108+
func Test_win_execute_closing_curwin()
109+
split
110+
let winid = popup_create('some text', {})
111+
call win_execute(winid, winnr() .. "close")
112+
call assert_equal(1, winnr())
113+
popupclear
114+
endfunc
115+
108116
func Test_popup_with_wrap()
109117
if !CanRunVimInTerminal()
110118
return

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,8 @@ static char *(features[]) =
767767

768768
static int included_patches[] =
769769
{ /* Add new patch number below this line */
770+
/**/
771+
1433,
770772
/**/
771773
1432,
772774
/**/

src/window.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6573,6 +6573,12 @@ restore_win_noblock(
65736573
curwin = save_curwin;
65746574
curbuf = curwin->w_buffer;
65756575
}
6576+
#ifdef FEAT_TEXT_PROP
6577+
else if (bt_popup(curwin->w_buffer))
6578+
// original window was closed and now we're in a popup window: Go
6579+
// to the first valid window.
6580+
win_goto(firstwin);
6581+
#endif
65766582
}
65776583

65786584
/*

0 commit comments

Comments
 (0)