]> granicus.if.org Git - vim/commitdiff
patch 8.2.1997: window changes when using bufload() while in a terminal popup v8.2.1997
authorBram Moolenaar <Bram@vim.org>
Mon, 16 Nov 2020 19:47:31 +0000 (20:47 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 16 Nov 2020 19:47:31 +0000 (20:47 +0100)
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)

src/testdir/test_terminal.vim
src/version.c
src/window.c

index 7d6bdbcf6cea63a6d81a9ead8f60d286888963b7..735164780c47ab0edf656805371e6c8957778d7e 100644 (file)
@@ -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
 
index 7aadd454f54b0a7a3a484864196132f3361ba887..0e9973e0971b8043f73a2333b6898584fe309e1e 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1997,
 /**/
     1996,
 /**/
index 501ea846a8a5eb70563de8e52e28a59896984d18..1134d0a6c0f66add4998be78dab0df12e13f2c95 100644 (file)
@@ -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;
 }