mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
fix(api): set correct curbuf when temporarily changing curwin (#21371)
This is the same code change as 6c87bbb4e4
This commit is contained in:
@@ -169,9 +169,11 @@ void nvim_win_set_height(Window window, Integer height, Error *err)
|
|||||||
|
|
||||||
win_T *savewin = curwin;
|
win_T *savewin = curwin;
|
||||||
curwin = win;
|
curwin = win;
|
||||||
|
curbuf = curwin->w_buffer;
|
||||||
try_start();
|
try_start();
|
||||||
win_setheight((int)height);
|
win_setheight((int)height);
|
||||||
curwin = savewin;
|
curwin = savewin;
|
||||||
|
curbuf = curwin->w_buffer;
|
||||||
try_end(err);
|
try_end(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,9 +216,11 @@ void nvim_win_set_width(Window window, Integer width, Error *err)
|
|||||||
|
|
||||||
win_T *savewin = curwin;
|
win_T *savewin = curwin;
|
||||||
curwin = win;
|
curwin = win;
|
||||||
|
curbuf = curwin->w_buffer;
|
||||||
try_start();
|
try_start();
|
||||||
win_setwidth((int)width);
|
win_setwidth((int)width);
|
||||||
curwin = savewin;
|
curwin = savewin;
|
||||||
|
curbuf = curwin->w_buffer;
|
||||||
try_end(err);
|
try_end(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -7,6 +7,7 @@ local clear, nvim, curbuf, curbuf_contents, window, curwin, eq, neq,
|
|||||||
helpers.tabpage
|
helpers.tabpage
|
||||||
local poke_eventloop = helpers.poke_eventloop
|
local poke_eventloop = helpers.poke_eventloop
|
||||||
local curwinmeths = helpers.curwinmeths
|
local curwinmeths = helpers.curwinmeths
|
||||||
|
local exec = helpers.exec
|
||||||
local funcs = helpers.funcs
|
local funcs = helpers.funcs
|
||||||
local request = helpers.request
|
local request = helpers.request
|
||||||
local NIL = helpers.NIL
|
local NIL = helpers.NIL
|
||||||
@@ -283,6 +284,22 @@ describe('API/win', function()
|
|||||||
window('set_height', nvim('list_wins')[2], 2)
|
window('set_height', nvim('list_wins')[2], 2)
|
||||||
eq(2, window('get_height', nvim('list_wins')[2]))
|
eq(2, window('get_height', nvim('list_wins')[2]))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('do not cause ml_get errors with foldmethod=expr #19989', function()
|
||||||
|
insert([[
|
||||||
|
aaaaa
|
||||||
|
bbbbb
|
||||||
|
ccccc]])
|
||||||
|
command('set foldmethod=expr')
|
||||||
|
exec([[
|
||||||
|
new
|
||||||
|
let w = nvim_get_current_win()
|
||||||
|
wincmd w
|
||||||
|
call nvim_win_set_height(w, 5)
|
||||||
|
]])
|
||||||
|
feed('l')
|
||||||
|
eq('', meths.get_vvar('errmsg'))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('{get,set}_width', function()
|
describe('{get,set}_width', function()
|
||||||
@@ -297,6 +314,22 @@ describe('API/win', function()
|
|||||||
window('set_width', nvim('list_wins')[2], 2)
|
window('set_width', nvim('list_wins')[2], 2)
|
||||||
eq(2, window('get_width', nvim('list_wins')[2]))
|
eq(2, window('get_width', nvim('list_wins')[2]))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('do not cause ml_get errors with foldmethod=expr #19989', function()
|
||||||
|
insert([[
|
||||||
|
aaaaa
|
||||||
|
bbbbb
|
||||||
|
ccccc]])
|
||||||
|
command('set foldmethod=expr')
|
||||||
|
exec([[
|
||||||
|
vnew
|
||||||
|
let w = nvim_get_current_win()
|
||||||
|
wincmd w
|
||||||
|
call nvim_win_set_width(w, 5)
|
||||||
|
]])
|
||||||
|
feed('l')
|
||||||
|
eq('', meths.get_vvar('errmsg'))
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('{get,set,del}_var', function()
|
describe('{get,set,del}_var', function()
|
||||||
|
Reference in New Issue
Block a user