summaryrefslogtreecommitdiff
path: root/script-beta/core/hover
diff options
context:
space:
mode:
Diffstat (limited to 'script-beta/core/hover')
-rw-r--r--script-beta/core/hover/label.lua2
-rw-r--r--script-beta/core/hover/table.lua19
2 files changed, 19 insertions, 2 deletions
diff --git a/script-beta/core/hover/label.lua b/script-beta/core/hover/label.lua
index dcfc21c3..5798317f 100644
--- a/script-beta/core/hover/label.lua
+++ b/script-beta/core/hover/label.lua
@@ -95,7 +95,7 @@ local function asString(source)
return ''
end
local len = #str
- local charLen = utf8.len(str, 1, -1, true)
+ local charLen = util.utf8Len(str, 1, -1)
-- TODO 翻译
if len == charLen then
return ('%d 个字节'):format(len)
diff --git a/script-beta/core/hover/table.lua b/script-beta/core/hover/table.lua
index 17316367..7b53979a 100644
--- a/script-beta/core/hover/table.lua
+++ b/script-beta/core/hover/table.lua
@@ -111,6 +111,23 @@ local function mergeLiteral(literals)
return table.concat(results, '|')
end
+local function mergeTypes(types)
+ local results = {}
+ local mark = {
+ -- 讲道理table的keyvalue不会是nil
+ ['nil'] = true,
+ }
+ for _, tv in ipairs(types) do
+ for tp in tv:gmatch '[^|]+' do
+ if not mark[tp] then
+ mark[tp] = true
+ results[#results+1] = tp
+ end
+ end
+ end
+ return guide.mergeTypes(results)
+end
+
local function clearClasses(classes)
local knownClasses = {
['any'] = true,
@@ -168,7 +185,7 @@ return function (source)
for key, class in pairs(classes) do
literals[key] = mergeLiteral(literals[key])
- classes[key] = guide.mergeTypes(class)
+ classes[key] = mergeTypes(class)
end
if not next(classes) then