clear_tv(&rettv);
}
+/*
+ * Make "prevwin" the current window, unless it's equal to "wp".
+ * Otherwise make "firstwin" the current window.
+ */
+ static void
+back_to_prevwin(win_T *wp)
+{
+ if (win_valid(prevwin) && wp != prevwin)
+ win_enter(prevwin, FALSE);
+ else
+ win_enter(firstwin, FALSE);
+}
+
/*
* Close popup "wp" and invoke any close callback for it.
*/
break;
if (owp != NULL)
win_enter(owp, FALSE);
- else if (win_valid(prevwin) && wp != prevwin)
- win_enter(prevwin, FALSE);
else
- win_enter(firstwin, FALSE);
+ back_to_prevwin(wp);
}
}
#endif
error_for_popup_window();
return FAIL;
}
- win_enter(firstwin, FALSE);
+ back_to_prevwin(wp);
}
if (prev == NULL)
first_popupwin = wp->w_next;
error_for_popup_window();
return FAIL;
}
- win_enter(firstwin, FALSE);
+ back_to_prevwin(wp);
}
if (prev == NULL)
*root = wp->w_next;
call assert_equal(origwin, win_getid())
endfunc
+func Test_popupwin_close_prevwin()
+ CheckFeature terminal
+
+ call assert_equal(1, winnr('$'))
+ split
+ wincmd b
+ call assert_equal(2, winnr())
+ let buf = term_start(&shell, #{hidden: 1})
+ call popup_create(buf, {})
+ call term_wait(buf, 100)
+ call popup_clear(1)
+ call assert_equal(2, winnr())
+
+ quit
+ exe 'bwipe! ' .. buf
+endfunc
+
func Test_popupwin_with_buffer_and_filter()
new Xwithfilter
call setline(1, range(100))