diff options
Diffstat (limited to 'script-beta/core/hover/label.lua')
-rw-r--r-- | script-beta/core/hover/label.lua | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/script-beta/core/hover/label.lua b/script-beta/core/hover/label.lua index e9b987e1..799ad662 100644 --- a/script-beta/core/hover/label.lua +++ b/script-beta/core/hover/label.lua @@ -89,6 +89,21 @@ local function asLibrary(source) end end +local function asString(source) + local str = source[1] + if type(str) ~= 'string' then + return '' + end + local len = #str + local charLen = utf8.len(str, 1, -1, true) + -- TODO 翻译 + if len == charLen then + return ('%d 个字节'):format(len) + else + return ('%d 个字节,%d 个字符'):format(len, charLen) + end +end + return function (source, caller) if source.type == 'function' then return asFunction(source, caller) @@ -107,5 +122,7 @@ return function (source, caller) or source.type == 'field' or source.type == 'method' then return asField(source) + elseif source.type == 'string' then + return asString(source) end end |