summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-06-01 14:15:52 +0200
committerBram Moolenaar <Bram@vim.org>2019-06-01 14:15:52 +0200
commit815b76bff618c07226653e11f29c4d3c5640b63a (patch)
treefbe1ffe3d0c5d15914bf9e7aaee5bc007e9390ab
parent3a97bb3f0f8bd118ae23f1c97e55d84ff42eef20 (diff)
patch 8.1.1438: some commands cause trouble in a popup windowv8.1.1438
Problem: Some commands cause trouble in a popup window. Solution: Add NOT_IN_POPUP_WINDOW.
-rw-r--r--src/ex_cmds2.c2
-rw-r--r--src/ex_docmd.c11
-rw-r--r--src/macros.h6
-rw-r--r--src/popupwin.c12
-rw-r--r--src/proto/popupwin.pro1
-rw-r--r--src/testdir/test_popupwin.vim23
-rw-r--r--src/version.c2
-rw-r--r--src/window.c17
8 files changed, 70 insertions, 4 deletions
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 5a33bb128c..66e5fca128 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -1864,6 +1864,8 @@ do_argfile(exarg_T *eap, int argn)
char_u *p;
int old_arg_idx = curwin->w_arg_idx;
+ if (NOT_IN_POPUP_WINDOW)
+ return;
if (argn < 0 || argn >= ARGCOUNT)
{
if (ARGCOUNT <= 1)
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 82f94629be..cc6a920a23 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -5452,6 +5452,8 @@ ex_doautocmd(exarg_T *eap)
static void
ex_bunload(exarg_T *eap)
{
+ if (NOT_IN_POPUP_WINDOW)
+ return;
eap->errmsg = do_bufdel(
eap->cmdidx == CMD_bdelete ? DOBUF_DEL
: eap->cmdidx == CMD_bwipeout ? DOBUF_WIPE
@@ -5466,6 +5468,8 @@ ex_bunload(exarg_T *eap)
static void
ex_buffer(exarg_T *eap)
{
+ if (NOT_IN_POPUP_WINDOW)
+ return;
if (*eap->arg)
eap->errmsg = e_trailing;
else
@@ -6768,6 +6772,9 @@ ex_splitview(exarg_T *eap)
|| eap->cmdidx == CMD_tabfind
|| eap->cmdidx == CMD_tabnew;
+ if (NOT_IN_POPUP_WINDOW)
+ return;
+
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
#endif
@@ -6895,6 +6902,8 @@ ex_tabnext(exarg_T *eap)
{
int tab_number;
+ if (NOT_IN_POPUP_WINDOW)
+ return;
switch (eap->cmdidx)
{
case CMD_tabfirst:
@@ -7146,6 +7155,8 @@ do_exedit(
int need_hide;
int exmode_was = exmode_active;
+ if (NOT_IN_POPUP_WINDOW)
+ return;
/*
* ":vi" command ends Ex mode.
*/
diff --git a/src/macros.h b/src/macros.h
index 8c0e04a56c..0f5ab7739d 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -339,3 +339,9 @@
/* Wether a command index indicates a user command. */
#define IS_USER_CMDIDX(idx) ((int)(idx) < 0)
+
+#ifdef FEAT_TEXT_PROP
+# define NOT_IN_POPUP_WINDOW not_in_popup_window()
+#else
+# define NOT_IN_POPUP_WINDOW 0
+#endif
diff --git a/src/popupwin.c b/src/popupwin.c
index 73b98beed1..2ebfda2d9c 100644
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -747,4 +747,16 @@ f_popup_getoptions(typval_T *argvars, typval_T *rettv)
# endif
}
}
+
+ int
+not_in_popup_window()
+{
+ if (bt_popup(curwin->w_buffer))
+ {
+ emsg(_("E994: Not allowed in a popup window"));
+ return TRUE;
+ }
+ return FALSE;
+}
+
#endif // FEAT_TEXT_PROP
diff --git a/src/proto/popupwin.pro b/src/proto/popupwin.pro
index eb9e241528..107a4273c5 100644
--- a/src/proto/popupwin.pro
+++ b/src/proto/popupwin.pro
@@ -13,4 +13,5 @@ void ex_popupclear(exarg_T *eap);
void f_popup_move(typval_T *argvars, typval_T *rettv);
void f_popup_getpos(typval_T *argvars, typval_T *rettv);
void f_popup_getoptions(typval_T *argvars, typval_T *rettv);
+int not_in_popup_window(void);
/* vim: set ft=c : */
diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim
index d0d27b5618..7c3cd94f08 100644
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -108,8 +108,27 @@ endfunc
func Test_win_execute_closing_curwin()
split
let winid = popup_create('some text', {})
- call win_execute(winid, winnr() .. "close")
- call assert_equal(1, winnr())
+ call assert_fails('call win_execute(winid, winnr() .. "close")', 'E994')
+ popupclear
+endfunc
+
+func Test_win_execute_not_allowed()
+ let winid = popup_create('some text', {})
+ call assert_fails('call win_execute(winid, "split")', 'E994:')
+ call assert_fails('call win_execute(winid, "vsplit")', 'E994:')
+ call assert_fails('call win_execute(winid, "close")', 'E994:')
+ call assert_fails('call win_execute(winid, "bdelete")', 'E994:')
+ call assert_fails('call win_execute(winid, "tabnew")', 'E994:')
+ call assert_fails('call win_execute(winid, "tabnext")', 'E994:')
+ call assert_fails('call win_execute(winid, "next")', 'E994:')
+ call assert_fails('call win_execute(winid, "rewind")', 'E994:')
+ call assert_fails('call win_execute(winid, "buf")', 'E994:')
+ call assert_fails('call win_execute(winid, "edit")', 'E994:')
+ call assert_fails('call win_execute(winid, "enew")', 'E994:')
+ call assert_fails('call win_execute(winid, "wincmd x")', 'E994:')
+ call assert_fails('call win_execute(winid, "wincmd w")', 'E994:')
+ call assert_fails('call win_execute(winid, "wincmd t")', 'E994:')
+ call assert_fails('call win_execute(winid, "wincmd b")', 'E994:')
popupclear
endfunc
diff --git a/src/version.c b/src/version.c
index c7c19f3984..4b380d2726 100644
--- a/src/version.c
+++ b/src/version.c
@@ -768,6 +768,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1438,
+/**/
1437,
/**/
1436,
diff --git a/src/window.c b/src/window.c
index e73a9f4921..42689ee0bc 100644
--- a/src/window.c
+++ b/src/window.c
@@ -87,7 +87,8 @@ do_window(
#endif
char_u cbuf[40];
- Prenum1 = Prenum == 0 ? 1 : Prenum;
+ if (NOT_IN_POPUP_WINDOW)
+ return;
#ifdef FEAT_CMDWIN
# define CHECK_CMDWIN \
@@ -102,6 +103,8 @@ do_window(
# define CHECK_CMDWIN do { /**/ } while (0)
#endif
+ Prenum1 = Prenum == 0 ? 1 : Prenum;
+
switch (nchar)
{
/* split current window in two parts, horizontally */
@@ -732,6 +735,9 @@ cmd_with_count(
int
win_split(int size, int flags)
{
+ if (NOT_IN_POPUP_WINDOW)
+ return FAIL;
+
/* When the ":tab" modifier was used open a new tab page instead. */
if (may_open_tabpage() == OK)
return OK;
@@ -1509,7 +1515,9 @@ win_exchange(long Prenum)
win_T *wp2;
int temp;
- if (ONE_WINDOW) /* just one window */
+ if (NOT_IN_POPUP_WINDOW)
+ return;
+ if (ONE_WINDOW) // just one window
{
beep_flush();
return;
@@ -2363,6 +2371,9 @@ win_close(win_T *win, int free_buf)
tabpage_T *prev_curtab = curtab;
frame_T *win_frame = win->w_frame->fr_parent;
+ if (NOT_IN_POPUP_WINDOW)
+ return FAIL;
+
if (last_window())
{
emsg(_("E444: Cannot close last window"));
@@ -4221,6 +4232,8 @@ win_goto(win_T *wp)
win_T *owp = curwin;
#endif
+ if (NOT_IN_POPUP_WINDOW)
+ return;
if (text_locked())
{
beep_flush();