summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-07-08 18:20:12 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-07-08 18:20:12 +0800
commit7b67c5d4dc31f0b49994d334e8353ca4430224d3 (patch)
tree80e39248f50e726516096d73068fdb7f8cdc29dc /script/core
parent011a5f1748da4d686a3cf34f22756e2f05968ebd (diff)
downloadlua-language-server-7b67c5d4dc31f0b49994d334e8353ca4430224d3.zip
#189 限制字符串的最大长度
Diffstat (limited to 'script/core')
-rw-r--r--script/core/hover/hover.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/script/core/hover/hover.lua b/script/core/hover/hover.lua
index 932883fc..d3a1a155 100644
--- a/script/core/hover/hover.lua
+++ b/script/core/hover/hover.lua
@@ -327,12 +327,16 @@ local function hoverAsString(source)
-- 内部包含转义符?
local rawLen = source.finish - source.start - 2 * #source[2] + 1
if (source[2] == '"' or source[2] == "'") and rawLen > #str then
+ local view = str
+ if #view > 1000 then
+ view = view:sub(1, 1000) .. '...'
+ end
lines[#lines+1] = ([[
------------------
```txt
%s
-```]]):format(str)
+```]]):format(view)
end
return {
description = table.concat(lines, '\n'),