summaryrefslogtreecommitdiff
path: root/script/workspace
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-01-25 17:02:28 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-01-25 17:02:28 +0800
commit41c0a3671ec1cc704a9414f75772542ceaaf60d4 (patch)
tree8193c57282dda1e87795e497194eb7a54648f7d4 /script/workspace
parentbccfab54e367efe4d2b3e34fabb28bf1c481434e (diff)
downloadlua-language-server-41c0a3671ec1cc704a9414f75772542ceaaf60d4.zip
fix #925
Diffstat (limited to 'script/workspace')
-rw-r--r--script/workspace/loading.lua1
-rw-r--r--script/workspace/require-path.lua11
-rw-r--r--script/workspace/scope.lua14
-rw-r--r--script/workspace/workspace.lua2
4 files changed, 17 insertions, 11 deletions
diff --git a/script/workspace/loading.lua b/script/workspace/loading.lua
index 0ef94320..5fc5a134 100644
--- a/script/workspace/loading.lua
+++ b/script/workspace/loading.lua
@@ -99,7 +99,6 @@ function mt:loadFile(uri, libraryUri)
files.addRef(uri)
if libraryUri then
log.info('++++As library of:', libraryUri)
- files.setLibraryUri(self.scp, uri, libraryUri)
end
end
elseif files.isDll(uri) then
diff --git a/script/workspace/require-path.lua b/script/workspace/require-path.lua
index c3dc92d3..f0a75eb1 100644
--- a/script/workspace/require-path.lua
+++ b/script/workspace/require-path.lua
@@ -56,9 +56,7 @@ function m.getVisiblePath(suri, path)
local result = cache[path]
if not result then
result = {}
- if libraryPath then
- cache[path] = result
- end
+ cache[path] = result
for _, searcher in ipairs(searchers) do
local isAbsolute = searcher:match '^[/\\]'
or searcher:match '^%a+%:'
@@ -71,11 +69,7 @@ function m.getVisiblePath(suri, path)
if libraryPath then
currentPath = currentPath:sub(#libraryPath + 2)
else
- local isRelative
- currentPath, isRelative = workspace.getRelativePath(uri)
- if not isAbsolute and not isRelative then
- goto CONTINUE
- end
+ currentPath = workspace.getRelativePath(uri)
end
end
repeat
@@ -100,7 +94,6 @@ function m.getVisiblePath(suri, path)
addRequireName(suri, uri, expect)
end
until not pos or strict
- ::CONTINUE::
end
end
return result
diff --git a/script/workspace/scope.lua b/script/workspace/scope.lua
index 711fc1a1..304e875e 100644
--- a/script/workspace/scope.lua
+++ b/script/workspace/scope.lua
@@ -56,6 +56,20 @@ function mt:isLinkedUri(uri)
return false
end
+---@param uri uri
+---@return uri?
+function mt:getLinkedUri(uri)
+ if not uri then
+ return nil
+ end
+ for linkUri in pairs(self._links) do
+ if uri:sub(1, #linkUri) == linkUri then
+ return linkUri
+ end
+ end
+ return nil
+end
+
---@param k string
---@param v any
function mt:set(k, v)
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua
index 9b8cb703..e8a61665 100644
--- a/script/workspace/workspace.lua
+++ b/script/workspace/workspace.lua
@@ -428,8 +428,8 @@ function m.awaitReload(scp)
scp:set('ready', false)
scp:set('nativeMatcher', nil)
scp:set('libraryMatcher', nil)
+ scp:removeAllLinks()
m.flushFiles(scp)
- files.flushAllLibrary(scp)
plugin.init(scp)
m.awaitPreload(scp)
scp:set('ready', true)