From c902388de8d140a1dbb979118ca705b47c52b51f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 7 Jul 2021 11:51:56 +0800 Subject: cleanup --- script/config/config.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'script/config') diff --git a/script/config/config.lua b/script/config/config.lua index 521e6817..61b09f4e 100644 --- a/script/config/config.lua +++ b/script/config/config.lua @@ -200,8 +200,13 @@ local Template = { ['editor.acceptSuggestionOnEnter'] = Type.String >> 'on', } -local config = {} -local raw = {} +local config = {} +local rawConfig = {} + +local function update(key, value, raw) + config[key] = value + rawConfig[key] = raw +end local m = {} @@ -211,11 +216,9 @@ function m.set(key, value) return end if unit:checker(value) then - config[key] = unit:loader(value) - raw[key] = value + update(key, unit:loader(value), value) else - config[key] = unit.default - raw[key] = unit.default + update(key, unit.default, unit.default) end end @@ -224,7 +227,7 @@ function m.add(key, value) if not unit then return end - local list = raw[key] + local list = rawConfig[key] if type(list) ~= 'table' then return end @@ -234,8 +237,7 @@ function m.add(key, value) end copyed[#copyed+1] = value if unit:checker(copyed) then - config[key] = unit:loader(copyed) - raw[key] = copyed + update(key, unit:loader(copyed), copyed) end end -- cgit v1.2.3