diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-08-17 15:58:56 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-08-17 15:58:56 +0800 |
commit | 65b0f5c0f90ee63ef3562be9a41be8fc5eaae4d5 (patch) | |
tree | 905b8ebd57698808ce9bfaf68835f5b60b473742 | |
parent | 56d37a64423660f854f8d64f05831d632442ea4e (diff) | |
download | lua-language-server-65b0f5c0f90ee63ef3562be9a41be8fc5eaae4d5.zip |
set aside
-rw-r--r-- | .vscode/settings.json | 2 | ||||
-rw-r--r-- | script/lazy-cacher.lua | 21 | ||||
-rw-r--r-- | script/lazytable.lua | 5 |
3 files changed, 21 insertions, 7 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json index 1170a63a..e7be186e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,6 +5,6 @@ "--develop=true", "--dbgport=11413", "--loglevel=trace", - "--lazy", + //"--lazy", ] } diff --git a/script/lazy-cacher.lua b/script/lazy-cacher.lua index e9f19210..e39cceff 100644 --- a/script/lazy-cacher.lua +++ b/script/lazy-cacher.lua @@ -1,4 +1,4 @@ -local fs = require 'bee.filesystem' +local fs = require 'bee.filesystem' ---@param path string ---@param errorHandle? fun(string) @@ -29,6 +29,13 @@ return function (path, errorHandle) end return false end + if not code then + map[id] = nil + return true + end + if #code > 1000000 then + return false + end local suc, err = f:write(code) if not suc then if errorHandle then @@ -36,13 +43,15 @@ return function (path, errorHandle) end return false end - map[id * 2] = offset - map[id * 2 + 1] = #code + map[id] = offset * 1000000 + #code return true end, reader = function(id) - local offset = map[id * 2] - local len = map[id * 2 + 1] + if not map[id] then + return nil + end + local offset = map[id] // 1000000 + local len = map[id] % 1000000 local _, err = f:seek('set', offset) if err then if errorHandle then @@ -55,7 +64,7 @@ return function (path, errorHandle) end, dispose = function () f:close() - os.remove(path) + fs.remove(fs.path(path)) end, } end diff --git a/script/lazytable.lua b/script/lazytable.lua index 344c56d0..9ac9c468 100644 --- a/script/lazytable.lua +++ b/script/lazytable.lua @@ -155,6 +155,11 @@ function mt:getObjectID(obj) return id end + if not next(obj) then + self.codeMap[id] = nil + return id + end + local fields = {} local objs for k, v in pairs(obj) do |