Mercurial > vim
diff src/popupwin.c @ 20474:3fe45aa3bbc5 v8.2.0791
patch 8.2.0791: a second popup window with terminal causes trouble
Commit: https://github.com/vim/vim/commit/b5383b174b2436b556f76f14badb1c1f55d6d8f6
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon May 18 19:46:48 2020 +0200
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 https://github.com/vim/vim/issues/6101,
closes #6103) Avoid defaulting to an invalid line number.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 18 May 2020 20:00:03 +0200 |
parents | 4c317d8c1051 |
children | 77995c0a9e78 |
line wrap: on
line diff
--- 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 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)