diff options
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r-- | runtime/lua/vim/_meta.lua | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/runtime/lua/vim/_meta.lua b/runtime/lua/vim/_meta.lua index e030c9ac81..416746b2cc 100644 --- a/runtime/lua/vim/_meta.lua +++ b/runtime/lua/vim/_meta.lua @@ -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, |