mirror of
https://github.com/neovim/neovim.git
synced 2025-12-13 18:12:50 +00:00
fix(vim.opt): Fix #14828 with empty values being incorrectly inserted
This commit is contained in:
@@ -414,6 +414,12 @@ local convert_value_to_lua = (function()
|
|||||||
return value
|
return value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Empty strings mean that there is nothing there,
|
||||||
|
-- so empty table should be returned.
|
||||||
|
if value == '' then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
-- Handles unescaped commas in a list.
|
-- Handles unescaped commas in a list.
|
||||||
if string.find(value, ",,,") then
|
if string.find(value, ",,,") then
|
||||||
local comma_split = vim.split(value, ",,,")
|
local comma_split = vim.split(value, ",,,")
|
||||||
@@ -451,6 +457,12 @@ local convert_value_to_lua = (function()
|
|||||||
[OptionTypes.SET] = function(info, value)
|
[OptionTypes.SET] = function(info, value)
|
||||||
if type(value) == "table" then return value end
|
if type(value) == "table" then return value end
|
||||||
|
|
||||||
|
-- Empty strings mean that there is nothing there,
|
||||||
|
-- so empty table should be returned.
|
||||||
|
if value == '' then
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
assert(info.flaglist, "That is the only one I know how to handle")
|
assert(info.flaglist, "That is the only one I know how to handle")
|
||||||
|
|
||||||
if info.flaglist and info.commalist then
|
if info.flaglist and info.commalist then
|
||||||
|
|||||||
@@ -1751,6 +1751,70 @@ describe('lua stdlib', function()
|
|||||||
|
|
||||||
eq({{"^,", "a", "b", "c"}, "a,b,^,,c"}, result)
|
eq({{"^,", "a", "b", "c"}, "a,b,^,,c"}, result)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
describe('https://github.com/neovim/neovim/issues/14828', function()
|
||||||
|
it('gives empty list when item is empty:array', function()
|
||||||
|
eq({}, exec_lua [[
|
||||||
|
vim.cmd("set wildignore=")
|
||||||
|
return vim.opt.wildignore:get()
|
||||||
|
]])
|
||||||
|
|
||||||
|
eq({}, exec_lua [[
|
||||||
|
vim.opt.wildignore = {}
|
||||||
|
return vim.opt.wildignore:get()
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('gives empty list when item is empty:set', function()
|
||||||
|
eq({}, exec_lua [[
|
||||||
|
vim.cmd("set formatoptions=")
|
||||||
|
return vim.opt.formatoptions:get()
|
||||||
|
]])
|
||||||
|
|
||||||
|
eq({}, exec_lua [[
|
||||||
|
vim.opt.formatoptions = {}
|
||||||
|
return vim.opt.formatoptions:get()
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('does not append to empty item', function()
|
||||||
|
eq({"*.foo", "*.bar"}, exec_lua [[
|
||||||
|
vim.opt.wildignore = {}
|
||||||
|
vim.opt.wildignore:append { "*.foo", "*.bar" }
|
||||||
|
|
||||||
|
return vim.opt.wildignore:get()
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('does not prepend to empty item', function()
|
||||||
|
eq({"*.foo", "*.bar"}, exec_lua [[
|
||||||
|
vim.opt.wildignore = {}
|
||||||
|
vim.opt.wildignore:prepend { "*.foo", "*.bar" }
|
||||||
|
|
||||||
|
return vim.opt.wildignore:get()
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('append to empty set', function()
|
||||||
|
eq({ t = true }, exec_lua [[
|
||||||
|
vim.opt.formatoptions = {}
|
||||||
|
vim.opt.formatoptions:append("t")
|
||||||
|
|
||||||
|
return vim.opt.formatoptions:get()
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('prepend to empty set', function()
|
||||||
|
eq({ t = true }, exec_lua [[
|
||||||
|
vim.opt.formatoptions = {}
|
||||||
|
vim.opt.formatoptions:prepend("t")
|
||||||
|
|
||||||
|
return vim.opt.formatoptions:get()
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
end)
|
||||||
end) -- vim.opt
|
end) -- vim.opt
|
||||||
|
|
||||||
it('vim.cmd', function()
|
it('vim.cmd', function()
|
||||||
|
|||||||
Reference in New Issue
Block a user