fix(vim.opt): #14708 Now lets you put duplicate values in wildmode

This commit is contained in:
TJ DeVries 2021-06-11 11:13:43 -04:00
parent f83c25942d
commit 1d3ee1c441
4 changed files with 16 additions and 4 deletions

View File

@ -325,9 +325,12 @@ local convert_value_to_vim = (function()
return result
end,
[OptionTypes.ARRAY] = function(_, value)
[OptionTypes.ARRAY] = function(info, value)
if type(value) == "string" then return value end
return table.concat(remove_duplicate_values(value), ",")
if not info.allows_duplicates then
value = remove_duplicate_values(value)
end
return table.concat(value, ",")
end,
[OptionTypes.MAP] = function(_, value)

View File

@ -7765,6 +7765,7 @@ static Dictionary vimoption2dict(vimoption_T *opt)
}
PUT(dict, "type", CSTR_TO_OBJ(type));
PUT(dict, "default", def);
PUT(dict, "allows_duplicates", BOOL(!(opt->flags & P_NODUP)));
return dict;
}

View File

@ -3152,7 +3152,7 @@ return {
full_name='wildmode', abbreviation='wim',
short_desc=N_("mode for 'wildchar' command-line expansion"),
type='string', list='onecomma', scope={'global'},
deny_duplicates=true,
deny_duplicates=false,
vim=true,
varname='p_wim',
defaults={if_true={vi="", vim="full"}}

View File

@ -1569,7 +1569,15 @@ describe('lua stdlib', function()
eq(wildignore, 'super_first,first,foo')
end)
end)
it('should not remove duplicates from wildmode: #14708', function()
local wildmode = exec_lua [[
vim.opt.wildmode = {"full", "list", "full"}
return vim.o.wildmode
]]
eq(wildmode, 'full,list,full')
end)
end) -- vim.opt
it('vim.cmd', function()
exec_lua [[