diff --git a/runtime/lua/vim/_core/options.lua b/runtime/lua/vim/_core/options.lua index d826df5c00..12c4f86232 100644 --- a/runtime/lua/vim/_core/options.lua +++ b/runtime/lua/vim/_core/options.lua @@ -435,6 +435,9 @@ local to_vim_value = { map = function(_, value) if type(value) == 'string' then return value + elseif vim.isarray(value) then + value = remove_duplicate_values(value) + return table.concat(value, ',') end local result = {} diff --git a/test/functional/lua/option_and_var_spec.lua b/test/functional/lua/option_and_var_spec.lua index eac74a5cc5..f4f54a4f30 100644 --- a/test/functional/lua/option_and_var_spec.lua +++ b/test/functional/lua/option_and_var_spec.lua @@ -778,7 +778,7 @@ describe('lua stdlib', function() eq(true, not formatoptions.q) end) - it('works for array list type options', function() + it('works for comma list type options', function() local wildignore = exec_lua(function() vim.opt.wildignore = '*.c,*.o,__pycache__' return vim.opt.wildignore:get() @@ -788,6 +788,13 @@ describe('lua stdlib', function() eq('*.c', wildignore[1]) end) + it('works for array list type options', function() + eq_exec_lua({ eol = '~', space = '-' }, function() + vim.opt.listchars = { 'eol:~', 'space:-' } + return vim.opt.listchars:get() + end) + end) + it('works for options that are both commalist and flaglist', function() eq_exec_lua({ b = true, s = true }, function() vim.opt.whichwrap = 'b,s'