diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-01-26 17:08:42 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-01-26 17:08:42 +0800 |
commit | 8357e5139dfbf1a474b98c4ec6539b360d38b06f (patch) | |
tree | 9111cf3c70c085bc4dd855b090e64a449156a984 /script | |
parent | d5b7d8f31c8f3325e8d769288000bb965f4ea35f (diff) | |
download | lua-language-server-8357e5139dfbf1a474b98c4ec6539b360d38b06f.zip |
`FIX` new files are not loaded correctly
Diffstat (limited to 'script')
-rw-r--r-- | script/workspace/loading.lua | 13 | ||||
-rw-r--r-- | script/workspace/workspace.lua | 1 |
2 files changed, 7 insertions, 7 deletions
diff --git a/script/workspace/loading.lua b/script/workspace/loading.lua index 5fc5a134..12683a23 100644 --- a/script/workspace/loading.lua +++ b/script/workspace/loading.lua @@ -81,13 +81,15 @@ function mt:loadFile(uri, libraryUri) if files.getFile(uri) then 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)) self.read = self.read + 1 self:update() - if self._cache[uri] then - return + if not self._cache[uri] then + files.addRef(uri) end self._cache[uri] = true if not content then @@ -96,7 +98,6 @@ function mt:loadFile(uri, libraryUri) log.info(('Preload file at: %s , size = %.3f KB'):format(uri, #content / 1024.0)) files.setText(uri, content, false) end - files.addRef(uri) if libraryUri then log.info('++++As library of:', libraryUri) end @@ -109,13 +110,14 @@ function mt:loadFile(uri, libraryUri) if files.getFile(uri) then self.read = self.read + 1 self:update() + files.addRef(uri) log.info(('Skip loaded file: %s'):format(uri)) else local content = pub.awaitTask('loadFile', furi.decode(uri)) self.read = self.read + 1 self:update() - if self._cache[uri] then - return + if not self._cache[uri] then + files.addRef(uri) end self._cache[uri] = true if not content then @@ -124,7 +126,6 @@ function mt:loadFile(uri, libraryUri) log.info(('Preload dll at: %s , size = %.3f KB'):format(uri, #content / 1024.0)) files.saveDll(uri, content) end - files.addRef(uri) if libraryUri then log.info('++++As library of:', libraryUri) end diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua index e8a61665..ad28d76b 100644 --- a/script/workspace/workspace.lua +++ b/script/workspace/workspace.lua @@ -228,7 +228,6 @@ function m.awaitLoadFile(uri) log.info('Scan files at:', uri) ---@async native:scan(furi.decode(uri), function (path) - files.remove(furi.encode(path)) ld:loadFile(furi.encode(path)) end) ld:loadAll() |