changeset 18084:f4b51934d4f8 v8.1.2037

patch 8.1.2037: can call win_gotoid() in cmdline window Commit: https://github.com/vim/vim/commit/a046b37c22bcabdea5f0fd6d21ca4bd0aa4c768e Author: Bram Moolenaar <Bram@vim.org> Date: Sun Sep 15 17:26:07 2019 +0200 patch 8.1.2037: can call win_gotoid() in cmdline window Problem: Can call win_gotoid() in cmdline window. Solution: Disallow switching windows. (Yasuhiro Matsumoto, closes https://github.com/vim/vim/issues/4940)
author Bram Moolenaar <Bram@vim.org>
date Sun, 15 Sep 2019 17:30:06 +0200
parents 940067fc8f0c
children 19946bad23ce
files src/evalwindow.c src/testdir/test_cmdline.vim src/version.c
diffstat 3 files changed, 30 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/evalwindow.c
+++ b/src/evalwindow.c
@@ -50,22 +50,6 @@ win_getid(typval_T *argvars)
     return 0;
 }
 
-    static int
-win_gotoid(typval_T *argvars)
-{
-    win_T	*wp;
-    tabpage_T   *tp;
-    int		id = tv_get_number(&argvars[0]);
-
-    FOR_ALL_TAB_WINDOWS(tp, wp)
-	    if (wp->w_id == id)
-	    {
-		goto_tabpage_win(tp, wp);
-		return 1;
-	    }
-    return 0;
-}
-
     static void
 win_id2tabwin(typval_T *argvars, list_T *list)
 {
@@ -705,7 +689,24 @@ f_win_getid(typval_T *argvars, typval_T 
     void
 f_win_gotoid(typval_T *argvars, typval_T *rettv)
 {
-    rettv->vval.v_number = win_gotoid(argvars);
+    win_T	*wp;
+    tabpage_T   *tp;
+    int		id = tv_get_number(&argvars[0]);
+
+#ifdef FEAT_CMDWIN
+    if (cmdwin_type != 0)
+    {
+	emsg(_(e_cmdwin));
+	return;
+    }
+#endif
+    FOR_ALL_TAB_WINDOWS(tp, wp)
+	if (wp->w_id == id)
+	{
+	    goto_tabpage_win(tp, wp);
+	    rettv->vval.v_number = 1;
+	    return;
+	}
 }
 
 /*
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -734,3 +734,13 @@ func Test_cmdline_overstrike()
 
   let &encoding = encoding_save
 endfunc
+
+func Test_cmdwin_bug()
+  let winid = win_getid()
+  sp
+  try
+    call feedkeys("q::call win_gotoid(" .. winid .. ")\<CR>:q\<CR>", 'x!')
+  catch /^Vim\%((\a\+)\)\=:E11/
+  endtry
+  bw!
+endfunc
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2037,
+/**/
     2036,
 /**/
     2035,