From b5383b174b2436b556f76f14badb1c1f55d6d8f6 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 18 May 2020 19:46:48 +0200 Subject: patch 8.2.0791: a second popup window with terminal causes trouble Problem: A second popup window with terminal causes trouble. Solution: Disallow opening a second terminal-popup window. (closes #6101, closes #6103) Avoid defaulting to an invalid line number. --- src/popupwin.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/popupwin.c') diff --git a/src/popupwin.c b/src/popupwin.c index 4ee097a06..79021c38c 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -1757,6 +1757,25 @@ add_border_left_right_padding(win_T *wp) } } +/* + * Return TRUE if there is any popup window with a terminal buffer. + */ + static int +popup_terminal_exists(void) +{ + win_T *wp; + tabpage_T *tp; + + FOR_ALL_POPUPWINS(wp) + if (wp->w_buffer->b_term != NULL) + return TRUE; + FOR_ALL_TABPAGES(tp) + FOR_ALL_POPUPWINS_IN_TAB(tp, wp) + if (wp->w_buffer->b_term != NULL) + return TRUE; + return FALSE; +} + /* * popup_create({text}, {options}) * popup_atcursor({text}, {options}) @@ -1786,6 +1805,13 @@ popup_create(typval_T *argvars, typval_T *rettv, create_type_T type) semsg(_(e_nobufnr), argvars[0].vval.v_number); return NULL; } +#ifdef FEAT_TERMINAL + if (buf->b_term != NULL && popup_terminal_exists()) + { + emsg(_("E861: Cannot open a second popup with a terminal")); + return NULL; + } +#endif } else if (!(argvars[0].v_type == VAR_STRING && argvars[0].vval.v_string != NULL) -- cgit v1.2.1