summaryrefslogtreecommitdiff
path: root/script/workspace
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-07-29 02:27:13 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-07-29 02:27:13 +0800
commit4190a3e8ebd0ff1408fc47927394970de952f18c (patch)
tree46d4ef193af05ef864a839135e990f6f5f5b2810 /script/workspace
parent87288efc77c68be375d6c534109f734f2cc99df9 (diff)
downloadlua-language-server-4190a3e8ebd0ff1408fc47927394970de952f18c.zip
fix runtime errors reported by telemetry
Diffstat (limited to 'script/workspace')
-rw-r--r--script/workspace/require-path.lua6
-rw-r--r--script/workspace/workspace.lua7
2 files changed, 8 insertions, 5 deletions
diff --git a/script/workspace/require-path.lua b/script/workspace/require-path.lua
index 204a22a6..8048f8ef 100644
--- a/script/workspace/require-path.lua
+++ b/script/workspace/require-path.lua
@@ -169,9 +169,9 @@ function mt:findUrisByRequireName(suri, name)
local searcherMap = {}
for _, searcher in ipairs(searchers) do
- local fspath = searcher:gsub('%?', path)
- if self.scp.uri then
- local fullPath = workspace.getAbsolutePath(self.scp.uri, fspath)
+ local fspath = searcher:gsub('%?', path:gsub('%%', '%%%%'))
+ local fullPath = workspace.getAbsolutePath(self.scp.uri, fspath)
+ if fullPath then
local fullUri = furi.encode(fullPath)
if files.exists(fullUri)
and fullUri ~= suri then
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua
index 973ae9ec..e69a4be4 100644
--- a/script/workspace/workspace.lua
+++ b/script/workspace/workspace.lua
@@ -404,12 +404,15 @@ function m.normalize(path)
return path
end
----@param folderUri uri
+---@param folderUri? uri
---@param path string
----@return string
+---@return string?
function m.getAbsolutePath(folderUri, path)
path = m.normalize(path)
if fs.path(path):is_relative() then
+ if not folderUri then
+ return nil
+ end
local folderPath = furi.decode(folderUri)
path = m.normalize(folderPath .. '/' .. path)
end