summaryrefslogtreecommitdiff
path: root/src/popupwin.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-05-18 19:46:48 +0200
committerBram Moolenaar <Bram@vim.org>2020-05-18 19:46:48 +0200
commitb5383b174b2436b556f76f14badb1c1f55d6d8f6 (patch)
tree9ac5d993e3a2febe97c8c77e19e1928a47bcf739 /src/popupwin.c
parent843700875e50c03c94245bef1b2de147b9b3b585 (diff)
downloadvim-git-b5383b174b2436b556f76f14badb1c1f55d6d8f6.tar.gz
patch 8.2.0791: a second popup window with terminal causes troublev8.2.0791
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.
Diffstat (limited to 'src/popupwin.c')
-rw-r--r--src/popupwin.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/popupwin.c b/src/popupwin.c
index 4ee097a06..79021c38c 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -1758,6 +1758,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})
* etc.
@@ -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)