aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Dewar <6256228+seandewar@users.noreply.github.com>2024-02-25 01:22:55 +0000
committerSean Dewar <6256228+seandewar@users.noreply.github.com>2024-03-08 23:24:05 +0000
commite3d4dfb6c3fcd22205f6843b96f9a043871113ce (patch)
tree653e2409b11eb8cd10d6a2d22431c7f97117a0a9
parentb2245307f2acfd7b62cf5d0c5b199c87c2d37b23 (diff)
downloadrneovim-e3d4dfb6c3fcd22205f6843b96f9a043871113ce.tar.gz
rneovim-e3d4dfb6c3fcd22205f6843b96f9a043871113ce.tar.bz2
rneovim-e3d4dfb6c3fcd22205f6843b96f9a043871113ce.zip
vim-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) https://github.com/vim/vim/commit/2a65e739447949a7aee966ce8a3b75521b2a79ea
-rw-r--r--src/nvim/eval/window.c5
-rw-r--r--test/old/testdir/test_window_cmd.vim6
2 files changed, 11 insertions, 0 deletions
diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c
index d20fc3f2f2..c2b9574579 100644
--- a/src/nvim/eval/window.c
+++ b/src/nvim/eval/window.c
@@ -584,6 +584,11 @@ void f_win_getid(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
void f_win_gotoid(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
{
int id = (int)tv_get_number(&argvars[0]);
+ if (curwin->handle == id) {
+ // Nothing to do.
+ rettv->vval.v_number = 1;
+ return;
+ }
if (text_or_buf_locked()) {
return;
diff --git a/test/old/testdir/test_window_cmd.vim b/test/old/testdir/test_window_cmd.vim
index 02fa3ac407..7ea556b11f 100644
--- a/test/old/testdir/test_window_cmd.vim
+++ b/test/old/testdir/test_window_cmd.vim
@@ -2173,6 +2173,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:')
@@ -2188,6 +2192,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