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.
diff --git a/src/popupwin.c b/src/popupwin.c
index 4ee097a..79021c3 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -1758,6 +1758,25 @@
}
/*
+ * 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 @@
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)