summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vscode/launch.json3
-rw-r--r--server/src/core/hover/hover.lua4
-rw-r--r--server/test/hover/init.lua5
3 files changed, 11 insertions, 1 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 28f7773f..baa8a471 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -29,7 +29,8 @@
"stopOnEntry": true,
"sourceCoding": "utf8",
"consoleCoding": "utf8",
- "address": "127.0.0.1:11411"
+ "address": "127.0.0.1:11411",
+ "outputCapture": []
},
{
"name": "编译",
diff --git a/server/src/core/hover/hover.lua b/server/src/core/hover/hover.lua
index dbbafc30..ca1e03d4 100644
--- a/server/src/core/hover/hover.lua
+++ b/server/src/core/hover/hover.lua
@@ -32,8 +32,12 @@ local function formatString(str)
str = str:sub(1000)
end
if str:find('[\r\n]') then
+ str = str:gsub('[\000-\008\011-\012\014-\031\127]', '')
return longString(str)
else
+ str = str:gsub('[\000-\008\011-\012\014-\031\127]', function (char)
+ return ('\\%03d'):format(char:byte())
+ end)
local single = str:find("'", 1, true)
local double = str:find('"', 1, true)
if single and double then
diff --git a/server/test/hover/init.lua b/server/test/hover/init.lua
index 88bc13d5..ea2631d4 100644
--- a/server/test/hover/init.lua
+++ b/server/test/hover/init.lua
@@ -466,6 +466,11 @@ function n<next>(table: table [, index: any])
]]
TEST[[
+local <?x?> = '\a'
+]]
+'local x: string = "\007"'
+
+TEST[[
---@class Class
local <?x?> = class()
]]