From ebb0cbc6cccb0b75507815939aa761ae625ba0df Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 20 Dec 2020 21:56:48 -0500 Subject: vim-patch:8.2.1966: popup becomes current window after closing a terminal window Problem: Popup becomes current window after closing a terminal window. Solution: When restoring the window after executing autocommands, check that the window ID is still the same. (Naruhiko Nishino, closes vim/vim#7272) https://github.com/vim/vim/commit/cbcd9cbd77acc8cc97c0d44683d96c01d3dd0fa7 --- src/nvim/window.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/nvim/window.c') diff --git a/src/nvim/window.c b/src/nvim/window.c index 0f17e2cb09..ad1e1f8f02 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1637,6 +1637,19 @@ bool win_valid(const win_T *win) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT return false; } +// Find window "handle" in the current tab page. +// Return NULL if not found. +win_T *win_find_by_handle(handle_T handle) + FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT +{ + FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { + if (wp->handle == handle) { + return wp; + } + } + return NULL; +} + /// Check if "win" is a pointer to an existing window in any tabpage. /// /// @param win window to check -- cgit