mirror of
https://github.com/neovim/neovim.git
synced 2025-12-07 23:22:39 +00:00
fix(vim.opt): Fix #14668 Now correctly handles unescaped commas in isfname style
This commit is contained in:
@@ -405,12 +405,46 @@ local convert_value_to_lua = (function()
|
|||||||
[OptionTypes.NUMBER] = function(_, value) return value end,
|
[OptionTypes.NUMBER] = function(_, value) return value end,
|
||||||
[OptionTypes.STRING] = 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
|
if type(value) == "table" then
|
||||||
value = remove_duplicate_values(value)
|
if not info.allows_duplicates then
|
||||||
|
value = remove_duplicate_values(value)
|
||||||
|
end
|
||||||
|
|
||||||
return value
|
return value
|
||||||
end
|
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, ",")
|
return vim.split(value, ",")
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
|||||||
@@ -2003,6 +2003,7 @@ describe('API', function()
|
|||||||
|
|
||||||
it('should have information about window options', function()
|
it('should have information about window options', function()
|
||||||
eq({
|
eq({
|
||||||
|
allows_duplicates = true,
|
||||||
commalist = false;
|
commalist = false;
|
||||||
default = "";
|
default = "";
|
||||||
flaglist = false;
|
flaglist = false;
|
||||||
@@ -2020,6 +2021,7 @@ describe('API', function()
|
|||||||
|
|
||||||
it('should have information about buffer options', function()
|
it('should have information about buffer options', function()
|
||||||
eq({
|
eq({
|
||||||
|
allows_duplicates = true,
|
||||||
commalist = false,
|
commalist = false,
|
||||||
default = "",
|
default = "",
|
||||||
flaglist = false,
|
flaglist = false,
|
||||||
@@ -2041,6 +2043,7 @@ describe('API', function()
|
|||||||
eq(false, meths.get_option'showcmd')
|
eq(false, meths.get_option'showcmd')
|
||||||
|
|
||||||
eq({
|
eq({
|
||||||
|
allows_duplicates = true,
|
||||||
commalist = false,
|
commalist = false,
|
||||||
default = true,
|
default = true,
|
||||||
flaglist = false,
|
flaglist = false,
|
||||||
|
|||||||
@@ -1731,6 +1731,26 @@ describe('lua stdlib', function()
|
|||||||
]]))
|
]]))
|
||||||
end)
|
end)
|
||||||
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
|
end) -- vim.opt
|
||||||
|
|
||||||
it('vim.cmd', function()
|
it('vim.cmd', function()
|
||||||
|
|||||||
Reference in New Issue
Block a user