# HG changeset patch # User Christian Brabandt # Date 1708628408 -3600 # Node ID 8c4339d56b1b1a3ff3eef555fb2503d89b2e1925 # Parent 07e17450d57aed5370d2d678e1688d5dbd3db727 patch 9.1.0128: win_gotoid() may abort even when not switching a window Commit: https://github.com/vim/vim/commit/2a65e739447949a7aee966ce8a3b75521b2a79ea Author: Sean Dewar <6256228+seandewar@users.noreply.github.com> Date: Thu Feb 22 19:53:33 2024 +0100 patch 9.1.0128: win_gotoid() may abort even when not switching a window 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 diff --git a/src/evalwindow.c b/src/evalwindow.c --- a/src/evalwindow.c +++ b/src/evalwindow.c @@ -824,6 +824,13 @@ f_win_gotoid(typval_T *argvars, typval_T 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) diff --git a/src/testdir/test_window_cmd.vim b/src/testdir/test_window_cmd.vim --- a/src/testdir/test_window_cmd.vim +++ b/src/testdir/test_window_cmd.vim @@ -2225,6 +2225,10 @@ func Test_win_gotoid_splitmove_textlock_ 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_ call feedkeys('q:' \ .. ":call assert_fails('call win_gotoid(win_getid(winnr(''#'')))', 'E11:')\" + "\ No error if attempting to switch to curwin; nothing happens. + \ .. ":call assert_equal(1, win_gotoid(win_getid()))\" \ .. ":call assert_equal('command', win_gettype())\" \ .. ":call assert_equal('', win_gettype(winnr('#')))\", 'ntx') endfunc diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -705,6 +705,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 128, +/**/ 127, /**/ 126,