0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 8.2.1997: window changes when using bufload() while in a terminal popup

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)
This commit is contained in:
Bram Moolenaar
2020-11-16 20:47:31 +01:00
parent 193f6201b4
commit 8adc8d9b73
3 changed files with 28 additions and 0 deletions

View File

@@ -1237,6 +1237,23 @@ func Test_terminal_popup_with_cmd()
unlet s:winid unlet s:winid
endfunc 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() func Test_terminal_popup_insert_cmd()
CheckUnix CheckUnix

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1997,
/**/ /**/
1996, 1996,
/**/ /**/

View File

@@ -1462,6 +1462,7 @@ win_valid(win_T *win)
/* /*
* Find window "id" in the current tab page. * Find window "id" in the current tab page.
* Also find popup windows.
* Return NULL if not found. * Return NULL if not found.
*/ */
win_T * win_T *
@@ -1472,6 +1473,14 @@ win_find_by_id(int id)
FOR_ALL_WINDOWS(wp) FOR_ALL_WINDOWS(wp)
if (wp->w_id == id) if (wp->w_id == id)
return wp; 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; return NULL;
} }