diff options
author | sumneko <sumneko@hotmail.com> | 2022-01-22 05:48:53 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2022-01-22 05:48:53 +0800 |
commit | 37d33caad5eca02ffa3ac0608ccfe13468bdd22e (patch) | |
tree | a481bde0654d8dcbdd8c54c000296e52f7ba29fb /test/tclient | |
parent | 877306a927b098e25853f38ea792dd5ee663bbfd (diff) | |
download | lua-language-server-37d33caad5eca02ffa3ac0608ccfe13468bdd22e.zip |
use async loadFile
Diffstat (limited to 'test/tclient')
-rw-r--r-- | test/tclient/lclient.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/tclient/lclient.lua b/test/tclient/lclient.lua index fa94481f..166add42 100644 --- a/test/tclient/lclient.lua +++ b/test/tclient/lclient.lua @@ -3,6 +3,7 @@ local util = require 'utility' local proto = require 'proto' local await = require 'await' local timer = require 'timer' +local pub = require 'pub' require 'provider' @@ -36,6 +37,23 @@ function mt:_flushServer() files.reset() end +function mt:_localLoadFile() + local awaitTask = pub.awaitTask + ---@async + ---@param name string + ---@param params any + pub.awaitTask = function (name, params) + if name == 'loadFile' then + local path = params + return util.loadFile(path) + end + return awaitTask(name, params) + end + self:gc(function () + pub.awaitTask = awaitTask + end) +end + ---@async function mt:initialize(params) self:awaitRequest('initialize', params or {}) @@ -60,6 +78,7 @@ end function mt:start(callback) self:_fakeProto() self:_flushServer() + self:_localLoadFile() local finished = false |