mirror of
https://github.com/neovim/neovim.git
synced 2025-10-04 08:56:29 +00:00
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)
2a65e73944
This commit is contained in:
@@ -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)
|
void f_win_gotoid(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||||
{
|
{
|
||||||
int id = (int)tv_get_number(&argvars[0]);
|
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()) {
|
if (text_or_buf_locked()) {
|
||||||
return;
|
return;
|
||||||
|
@@ -2173,6 +2173,10 @@ func Test_win_gotoid_splitmove_textlock_cmdwin()
|
|||||||
set debug+=throw indentexpr=win_gotoid(win_getid(winnr('#')))
|
set debug+=throw indentexpr=win_gotoid(win_getid(winnr('#')))
|
||||||
call assert_fails('normal! ==', 'E565:')
|
call assert_fails('normal! ==', 'E565:')
|
||||||
call assert_equal(curwin, win_getid())
|
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())
|
set indentexpr=win_splitmove(winnr('#'),winnr())
|
||||||
call assert_fails('normal! ==', 'E565:')
|
call assert_fails('normal! ==', 'E565:')
|
||||||
@@ -2188,6 +2192,8 @@ func Test_win_gotoid_splitmove_textlock_cmdwin()
|
|||||||
|
|
||||||
call feedkeys('q:'
|
call feedkeys('q:'
|
||||||
\ .. ":call assert_fails('call win_gotoid(win_getid(winnr(''#'')))', 'E11:')\<CR>"
|
\ .. ":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('command', win_gettype())\<CR>"
|
||||||
\ .. ":call assert_equal('', win_gettype(winnr('#')))\<CR>", 'ntx')
|
\ .. ":call assert_equal('', win_gettype(winnr('#')))\<CR>", 'ntx')
|
||||||
endfunc
|
endfunc
|
||||||
|
Reference in New Issue
Block a user