mirror of
https://github.com/neovim/neovim.git
synced 2026-04-19 14:00:49 +00:00
fix(vim.opt): Fix #14669 whichwrap now acts as expected
This commit is contained in:
@@ -267,7 +267,7 @@ local key_value_options = {
|
||||
winhl = true,
|
||||
}
|
||||
|
||||
---@class OptionType
|
||||
---@class OptionTypes
|
||||
--- Option Type Enum
|
||||
local OptionTypes = setmetatable({
|
||||
BOOLEAN = 0,
|
||||
@@ -342,14 +342,29 @@ local convert_value_to_vim = (function()
|
||||
[OptionTypes.NUMBER] = function(_, value) return value end,
|
||||
[OptionTypes.STRING] = function(_, value) return value end,
|
||||
|
||||
[OptionTypes.SET] = function(_, value)
|
||||
[OptionTypes.SET] = function(info, value)
|
||||
if type(value) == "string" then return value end
|
||||
local result = ''
|
||||
for k in pairs(value) do
|
||||
result = result .. k
|
||||
end
|
||||
|
||||
return result
|
||||
if info.flaglist and info.commalist then
|
||||
local keys = {}
|
||||
for k, v in pairs(value) do
|
||||
if v then
|
||||
table.insert(keys, k)
|
||||
end
|
||||
end
|
||||
|
||||
table.sort(keys)
|
||||
return table.concat(keys, ",")
|
||||
else
|
||||
local result = ''
|
||||
for k, v in pairs(value) do
|
||||
if v then
|
||||
result = result .. k
|
||||
end
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end,
|
||||
|
||||
[OptionTypes.ARRAY] = function(info, value)
|
||||
@@ -404,12 +419,22 @@ local convert_value_to_lua = (function()
|
||||
|
||||
assert(info.flaglist, "That is the only one I know how to handle")
|
||||
|
||||
local result = {}
|
||||
for i = 1, #value do
|
||||
result[value:sub(i, i)] = true
|
||||
end
|
||||
if info.flaglist and info.commalist then
|
||||
local split_value = vim.split(value, ",")
|
||||
local result = {}
|
||||
for _, v in ipairs(split_value) do
|
||||
result[v] = true
|
||||
end
|
||||
|
||||
return result
|
||||
return result
|
||||
else
|
||||
local result = {}
|
||||
for i = 1, #value do
|
||||
result[value:sub(i, i)] = true
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
end,
|
||||
|
||||
[OptionTypes.MAP] = function(info, raw_value)
|
||||
|
||||
@@ -1314,6 +1314,22 @@ describe('lua stdlib', function()
|
||||
eq("*.c", wildignore[1])
|
||||
end)
|
||||
|
||||
it('should work for options that are both commalist and flaglist', function()
|
||||
local result = exec_lua [[
|
||||
vim.opt.whichwrap = "b,s"
|
||||
return vim.opt.whichwrap:get()
|
||||
]]
|
||||
|
||||
eq({b = true, s = true}, result)
|
||||
|
||||
result = exec_lua [[
|
||||
vim.opt.whichwrap = { b = true, s = false, h = true }
|
||||
return vim.opt.whichwrap:get()
|
||||
]]
|
||||
|
||||
eq({b = true, h = true}, result)
|
||||
end)
|
||||
|
||||
it('should work for key-value pair options', function()
|
||||
local listchars = exec_lua [[
|
||||
vim.opt.listchars = "tab:>~,space:_"
|
||||
@@ -1695,7 +1711,8 @@ describe('lua stdlib', function()
|
||||
}
|
||||
return vim.go.whichwrap
|
||||
]]
|
||||
eq(true, ww == "bs" or ww == "sb")
|
||||
|
||||
eq(ww, "b,s")
|
||||
eq("b,s,<,>,[,]", exec_lua [[
|
||||
vim.opt.whichwrap = "b,s,<,>,[,]"
|
||||
return vim.go.whichwrap
|
||||
|
||||
Reference in New Issue
Block a user