mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 13:15:09 -07:00
fix(vim.opt): Fix #14668 Now correctly handles unescaped commas in isfname style
This commit is contained in:
parent
9119ea1bec
commit
6ecec87c09
@ -405,12 +405,46 @@ local convert_value_to_lua = (function()
|
||||
[OptionTypes.NUMBER] = function(_, value) return value end,
|
||||
[OptionTypes.STRING] = function(_, value) return value end,
|
||||
|
||||
[OptionTypes.ARRAY] = function(_, value)
|
||||
[OptionTypes.ARRAY] = function(info, value)
|
||||
if type(value) == "table" then
|
||||
value = remove_duplicate_values(value)
|
||||
if not info.allows_duplicates then
|
||||
value = remove_duplicate_values(value)
|
||||
end
|
||||
|
||||
return value
|
||||
end
|
||||
|
||||
-- Handles unescaped commas in a list.
|
||||
if string.find(value, ",,,") then
|
||||
local comma_split = vim.split(value, ",,,")
|
||||
local left = comma_split[1]
|
||||
local right = comma_split[2]
|
||||
|
||||
local result = {}
|
||||
vim.list_extend(result, vim.split(left, ","))
|
||||
table.insert(result, ",")
|
||||
vim.list_extend(result, vim.split(right, ","))
|
||||
|
||||
table.sort(result)
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
if string.find(value, ",^,,", 1, true) then
|
||||
local comma_split = vim.split(value, ",^,,", true)
|
||||
local left = comma_split[1]
|
||||
local right = comma_split[2]
|
||||
|
||||
local result = {}
|
||||
vim.list_extend(result, vim.split(left, ","))
|
||||
table.insert(result, "^,")
|
||||
vim.list_extend(result, vim.split(right, ","))
|
||||
|
||||
table.sort(result)
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
return vim.split(value, ",")
|
||||
end,
|
||||
|
||||
|
@ -2003,6 +2003,7 @@ describe('API', function()
|
||||
|
||||
it('should have information about window options', function()
|
||||
eq({
|
||||
allows_duplicates = true,
|
||||
commalist = false;
|
||||
default = "";
|
||||
flaglist = false;
|
||||
@ -2020,6 +2021,7 @@ describe('API', function()
|
||||
|
||||
it('should have information about buffer options', function()
|
||||
eq({
|
||||
allows_duplicates = true,
|
||||
commalist = false,
|
||||
default = "",
|
||||
flaglist = false,
|
||||
@ -2041,6 +2043,7 @@ describe('API', function()
|
||||
eq(false, meths.get_option'showcmd')
|
||||
|
||||
eq({
|
||||
allows_duplicates = true,
|
||||
commalist = false,
|
||||
default = true,
|
||||
flaglist = false,
|
||||
|
@ -1731,6 +1731,26 @@ describe('lua stdlib', function()
|
||||
]]))
|
||||
end)
|
||||
end)
|
||||
|
||||
-- isfname=a,b,c,,,d,e,f
|
||||
it('can handle isfname ,,,', function()
|
||||
local result = exec_lua [[
|
||||
vim.opt.isfname = "a,b,,,c"
|
||||
return { vim.opt.isfname:get(), vim.api.nvim_get_option('isfname') }
|
||||
]]
|
||||
|
||||
eq({{",", "a", "b", "c"}, "a,b,,,c"}, result)
|
||||
end)
|
||||
|
||||
-- isfname=a,b,c,^,,def
|
||||
it('can handle isfname ,^,,', function()
|
||||
local result = exec_lua [[
|
||||
vim.opt.isfname = "a,b,^,,c"
|
||||
return { vim.opt.isfname:get(), vim.api.nvim_get_option('isfname') }
|
||||
]]
|
||||
|
||||
eq({{"^,", "a", "b", "c"}, "a,b,^,,c"}, result)
|
||||
end)
|
||||
end) -- vim.opt
|
||||
|
||||
it('vim.cmd', function()
|
||||
|
Loading…
Reference in New Issue
Block a user