diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-11-16 20:47:31 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-11-16 20:47:31 +0100 |
commit | 8adc8d9b73121b647476a33d91d31d25e1c2d987 (patch) | |
tree | 16e0e7e503690996d9214a510632b76c0acf8cb3 | |
parent | 193f6201b4d5c76f8dc1faa1dcf369575d93fe3a (diff) | |
download | vim-git-8adc8d9b73121b647476a33d91d31d25e1c2d987.tar.gz |
patch 8.2.1997: window changes when using bufload() while in a terminal popupv8.2.1997
Problem: Window changes when using bufload() while in a terminal popup.
Solution: When searching for a window by ID also find a popup window.
(closes #7307)
-rw-r--r-- | src/testdir/test_terminal.vim | 17 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/window.c | 9 |
3 files changed, 28 insertions, 0 deletions
diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim index 7d6bdbcf6..735164780 100644 --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -1237,6 +1237,23 @@ func Test_terminal_popup_with_cmd() unlet s:winid endfunc +func Test_terminal_popup_bufload() + let termbuf = term_start(&shell, #{hidden: v:true, term_finish: 'close'}) + let winid = popup_create(termbuf, {}) + sleep 50m + + let newbuf = bufadd('') + call bufload(newbuf) + call setbufline(newbuf, 1, 'foobar') + + " must not have switched to another window + call assert_equal(winid, win_getid()) + + call feedkeys("exit\<CR>", 'xt') + sleep 50m + exe 'bwipe! ' .. newbuf +endfunc + func Test_terminal_popup_insert_cmd() CheckUnix diff --git a/src/version.c b/src/version.c index 7aadd454f..0e9973e09 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1997, +/**/ 1996, /**/ 1995, diff --git a/src/window.c b/src/window.c index 501ea846a..1134d0a6c 100644 --- a/src/window.c +++ b/src/window.c @@ -1462,6 +1462,7 @@ win_valid(win_T *win) /* * Find window "id" in the current tab page. + * Also find popup windows. * Return NULL if not found. */ win_T * @@ -1472,6 +1473,14 @@ win_find_by_id(int id) FOR_ALL_WINDOWS(wp) if (wp->w_id == id) return wp; +#ifdef FEAT_PROP_POPUP + FOR_ALL_POPUPWINS(wp) + if (wp->w_id == id) + return wp; + FOR_ALL_POPUPWINS_IN_TAB(curtab, wp) + if (wp->w_id == id) + return wp; +#endif return NULL; } |