summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2022-01-23 05:25:14 +0800
committersumneko <sumneko@hotmail.com>2022-01-23 05:25:14 +0800
commit21e40d69653771028a2e32bbc75fcfd90895d7b7 (patch)
treef257af67d40f4ebe4eab761c0280504ea9648635
parentd9a7e4bf6b521d60aef110a62a053d417416af85 (diff)
downloadlua-language-server-21e40d69653771028a2e32bbc75fcfd90895d7b7.zip
dont cache first
-rw-r--r--script/workspace/loading.lua24
-rw-r--r--script/workspace/require-path.lua11
2 files changed, 15 insertions, 20 deletions
diff --git a/script/workspace/loading.lua b/script/workspace/loading.lua
index 6e508181..41aa3537 100644
--- a/script/workspace/loading.lua
+++ b/script/workspace/loading.lua
@@ -82,10 +82,6 @@ function mt:loadFile(uri, libraryUri)
self.read = self.read + 1
self:update()
log.info(('Skip loaded file: %s'):format(uri))
- if libraryUri then
- log.info('++++As library of:', libraryUri)
- files.setLibraryUri(self.scp, uri, libraryUri)
- end
else
local content = pub.awaitTask('loadFile', furi.decode(uri))
if self._cache[uri] then
@@ -98,14 +94,13 @@ function mt:loadFile(uri, libraryUri)
return
end
log.info(('Preload file at: %s , size = %.3f KB'):format(uri, #content / 1024.0))
- files.setText(uri, content, false, function ()
- if libraryUri then
- log.info('++++As library of:', libraryUri)
- files.setLibraryUri(self.scp, uri, libraryUri)
- end
- end)
+ files.setText(uri, content, false)
end
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
self.max = self.max + 1
@@ -116,9 +111,6 @@ function mt:loadFile(uri, libraryUri)
self.read = self.read + 1
self:update()
log.info(('Skip loaded file: %s'):format(uri))
- if libraryUri then
- log.info('++++As library of:', libraryUri)
- end
else
local content = pub.awaitTask('loadFile', furi.decode(uri))
if self._cache[uri] then
@@ -132,11 +124,11 @@ function mt:loadFile(uri, libraryUri)
end
log.info(('Preload dll at: %s , size = %.3f KB'):format(uri, #content / 1024.0))
files.saveDll(uri, content)
- if libraryUri then
- log.info('++++As library of:', libraryUri)
- end
end
files.addRef(uri)
+ if libraryUri then
+ log.info('++++As library of:', libraryUri)
+ end
end
end
await.delay()
diff --git a/script/workspace/require-path.lua b/script/workspace/require-path.lua
index 223d6ada..7d6db35b 100644
--- a/script/workspace/require-path.lua
+++ b/script/workspace/require-path.lua
@@ -46,9 +46,12 @@ function m.getVisiblePath(suri, path)
local libraryPath = furi.decode(files.getLibraryUri(suri, uri))
local scp = scope.getScope(suri)
local cache = scp:get('visiblePath') or scp:set('visiblePath', {})
- if not cache[path] then
- local result = {}
- cache[path] = result
+ local result = cache[path]
+ if not result then
+ result = {}
+ if libraryPath then
+ cache[path] = result
+ end
for _, searcher in ipairs(searchers) do
local isAbsolute = searcher:match '^[/\\]'
or searcher:match '^%a+%:'
@@ -88,7 +91,7 @@ function m.getVisiblePath(suri, path)
until not pos or strict
end
end
- return cache[path]
+ return result
end
--- 查找符合指定require path的所有uri