summaryrefslogtreecommitdiff
path: root/script/workspace
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-01-26 21:29:00 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-01-26 21:29:00 +0800
commitf5991c0f4b90c6392d139decfecd00b25d1a2690 (patch)
tree39ede8de00d6c61fbccc3457077bba511a0b9319 /script/workspace
parentc513bcd6149bb3467b17b20a106087b8f418a0b1 (diff)
downloadlua-language-server-f5991c0f4b90c6392d139decfecd00b25d1a2690.zip
improve
Diffstat (limited to 'script/workspace')
-rw-r--r--script/workspace/loading.lua2
-rw-r--r--script/workspace/workspace.lua5
2 files changed, 5 insertions, 2 deletions
diff --git a/script/workspace/loading.lua b/script/workspace/loading.lua
index aedd74a0..2ea981e7 100644
--- a/script/workspace/loading.lua
+++ b/script/workspace/loading.lua
@@ -111,6 +111,7 @@ function mt:loadFile(uri, libraryUri)
self.read = self.read + 1
self:update()
files.addRef(uri)
+ self._cache[uri] = true
log.info(('Skip loaded file: %s'):format(uri))
else
local content = pub.awaitTask('loadFile', furi.decode(uri))
@@ -176,7 +177,6 @@ function m.create(scp)
_stash = {},
_cache = {},
}, mt)
- scp:set('cachedUris', loading._cache)
m._loadings[loading] = true
return loading
end
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua
index cb1ad58c..31566e32 100644
--- a/script/workspace/workspace.lua
+++ b/script/workspace/workspace.lua
@@ -228,6 +228,7 @@ function m.awaitLoadFile(uri)
log.info('Scan files at:', uri)
---@async
native:scan(furi.decode(uri), function (path)
+ scp:get('cachedUris')[furi.encode(path)] = true
ld:loadFile(furi.encode(path))
end)
ld:loadAll()
@@ -275,6 +276,7 @@ function m.awaitPreload(scp)
log.info('Scan files at:', scp:getName())
---@async
native:scan(furi.decode(scp.uri), function (path)
+ scp:get('cachedUris')[furi.encode(path)] = true
ld:loadFile(furi.encode(path))
end)
end
@@ -284,6 +286,7 @@ function m.awaitPreload(scp)
scp:addLink(libMatcher.uri)
---@async
libMatcher.matcher:scan(furi.decode(libMatcher.uri), function (path)
+ scp:get('cachedUris')[furi.encode(path)] = true
ld:loadFile(furi.encode(path), libMatcher.uri)
end)
watchers[#watchers+1] = fw.watch(furi.decode(libMatcher.uri))
@@ -401,10 +404,10 @@ end
---@param scp scope
function m.flushFiles(scp)
local cachedUris = scp:get 'cachedUris'
+ scp:set('cachedUris', {})
if not cachedUris then
return
end
- scp:set('cachedUris', nil)
for uri in pairs(cachedUris) do
files.delRef(uri)
end