mirror of
https://github.com/neovim/neovim
synced 2025-07-16 09:11:51 +00:00
fix(vim.wo): never allow non-zero bufnr
This commit is contained in:
@ -174,6 +174,11 @@ local function new_buf_opt_accessor(bufnr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function new_win_opt_accessor(winid, bufnr)
|
local function new_win_opt_accessor(winid, bufnr)
|
||||||
|
-- TODO(lewis6991): allow passing both buf and win to nvim_get_option_value
|
||||||
|
if bufnr ~= nil and bufnr ~= 0 then
|
||||||
|
error('only bufnr=0 is supported')
|
||||||
|
end
|
||||||
|
|
||||||
return setmetatable({}, {
|
return setmetatable({}, {
|
||||||
__index = function(_, k)
|
__index = function(_, k)
|
||||||
if bufnr == nil and type(k) == 'number' then
|
if bufnr == nil and type(k) == 'number' then
|
||||||
@ -184,11 +189,6 @@ local function new_win_opt_accessor(winid, bufnr)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if bufnr ~= nil and bufnr ~= 0 then
|
|
||||||
error('only bufnr=0 is supported')
|
|
||||||
end
|
|
||||||
|
|
||||||
-- TODO(lewis6991): allow passing both buf and win to nvim_get_option_value
|
|
||||||
return api.nvim_get_option_value(k, {
|
return api.nvim_get_option_value(k, {
|
||||||
scope = bufnr and 'local' or nil,
|
scope = bufnr and 'local' or nil,
|
||||||
win = winid or 0,
|
win = winid or 0,
|
||||||
@ -196,7 +196,6 @@ local function new_win_opt_accessor(winid, bufnr)
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
__newindex = function(_, k, v)
|
__newindex = function(_, k, v)
|
||||||
-- TODO(lewis6991): allow passing both buf and win to nvim_set_option_value
|
|
||||||
return api.nvim_set_option_value(k, v, {
|
return api.nvim_set_option_value(k, v, {
|
||||||
scope = bufnr and 'local' or nil,
|
scope = bufnr and 'local' or nil,
|
||||||
win = winid or 0,
|
win = winid or 0,
|
||||||
|
@ -2023,6 +2023,16 @@ describe('lua stdlib', function()
|
|||||||
vim.cmd "enew"
|
vim.cmd "enew"
|
||||||
]]
|
]]
|
||||||
eq(100, fn.luaeval 'vim.wo.scrolloff')
|
eq(100, fn.luaeval 'vim.wo.scrolloff')
|
||||||
|
|
||||||
|
matches(
|
||||||
|
'only bufnr=0 is supported',
|
||||||
|
pcall_err(exec_lua, 'vim.wo[0][10].signcolumn = "no"')
|
||||||
|
)
|
||||||
|
|
||||||
|
matches(
|
||||||
|
'only bufnr=0 is supported',
|
||||||
|
pcall_err(exec_lua, 'local a = vim.wo[0][10].signcolumn')
|
||||||
|
)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('vim.opt', function()
|
describe('vim.opt', function()
|
||||||
|
Reference in New Issue
Block a user