]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0128: win_gotoid() may abort even when not switching a window v9.1.0128
authorSean Dewar <6256228+seandewar@users.noreply.github.com>
Thu, 22 Feb 2024 18:53:33 +0000 (19:53 +0100)
committerChristian Brabandt <cb@256bit.org>
Thu, 22 Feb 2024 18:53:33 +0000 (19:53 +0100)
Problem:  win_gotoid() checks for textlock and other things when switching
          to a window that is already current (after v9.1.0119)
Solution: return early with success when attempting to switch to curwin
          (Sean Dewar)

Other potential causes of E565 from win_gotoid after v9.1.0119 should be
correct. Plugins can consider using win_execute() instead if they wish to
temporarily switch windows during textlock.

fixes: #14073
closes: #14074

Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/evalwindow.c
src/testdir/test_window_cmd.vim
src/version.c

index 00081d43d592a64513ca10ad5b32aafbc9c40959..f9b1c12961f2cd9acda3a675e997790f17a04879 100644 (file)
@@ -824,6 +824,13 @@ f_win_gotoid(typval_T *argvars, typval_T *rettv)
        return;
 
     id = tv_get_number(&argvars[0]);
+    if (curwin->w_id == id)
+    {
+       // Nothing to do.
+       rettv->vval.v_number = 1;
+       return;
+    }
+
     if (text_or_buf_locked())
        return;
 #if defined(FEAT_PROP_POPUP) && defined(FEAT_TERMINAL)
index a68ed74cb6ce35a70b011f0720d470d9c6d15de4..a70fb790c57788006f0abcd1386598f77281fab0 100644 (file)
@@ -2225,6 +2225,10 @@ func Test_win_gotoid_splitmove_textlock_cmdwin()
   set debug+=throw indentexpr=win_gotoid(win_getid(winnr('#')))
   call assert_fails('normal! ==', 'E565:')
   call assert_equal(curwin, win_getid())
+  " No error if attempting to switch to curwin; nothing happens.
+  set indentexpr=assert_equal(1,win_gotoid(win_getid()))
+  normal! ==
+  call assert_equal(curwin, win_getid())
 
   set indentexpr=win_splitmove(winnr('#'),winnr())
   call assert_fails('normal! ==', 'E565:')
@@ -2240,6 +2244,8 @@ func Test_win_gotoid_splitmove_textlock_cmdwin()
 
   call feedkeys('q:'
            \ .. ":call assert_fails('call win_gotoid(win_getid(winnr(''#'')))', 'E11:')\<CR>"
+           "\ No error if attempting to switch to curwin; nothing happens.
+           \ .. ":call assert_equal(1, win_gotoid(win_getid()))\<CR>"
            \ .. ":call assert_equal('command', win_gettype())\<CR>"
            \ .. ":call assert_equal('', win_gettype(winnr('#')))\<CR>", 'ntx')
 endfunc
index e2d1f591ab47c7878c7f202a4e56d3b5a0fdf7ac..9b38a34964edadd25254e31de030091764678b9d 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    128,
 /**/
     127,
 /**/