diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-09-27 16:02:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-27 16:02:40 +0800 |
commit | 4c51da51064bb825563827d0610a1e3db75299aa (patch) | |
tree | d3f1d5263f8435c6e223ef04608177ac9b448542 /script/proto | |
parent | 55e30e88ba33a28acc53265b249860b0bbc06fba (diff) | |
parent | 2f4f3e185b82ac16364e3a6150b8e1a7c5b1cdf9 (diff) | |
download | lua-language-server-4c51da51064bb825563827d0610a1e3db75299aa.zip |
Merge branch 'master' into improve-semantic-highlighting
Diffstat (limited to 'script/proto')
-rw-r--r-- | script/proto/define.lua | 1 | ||||
-rw-r--r-- | script/proto/proto.lua | 15 |
2 files changed, 13 insertions, 3 deletions
diff --git a/script/proto/define.lua b/script/proto/define.lua index 731c5cc6..fa351abb 100644 --- a/script/proto/define.lua +++ b/script/proto/define.lua @@ -173,6 +173,7 @@ m.ErrorCodes = { UnknownErrorCode = -32001, -- Defined by the protocol. + ContentModified = -32801, RequestCancelled = -32800, } diff --git a/script/proto/proto.lua b/script/proto/proto.lua index 61306b9f..7767ec0a 100644 --- a/script/proto/proto.lua +++ b/script/proto/proto.lua @@ -116,7 +116,7 @@ function m.doMethod(proto) return end if proto.id then - m.holdon[proto.id] = method + m.holdon[proto.id] = proto end await.call(function () --log.debug('Start method:', method) @@ -124,7 +124,7 @@ function m.doMethod(proto) await.setID('proto:' .. proto.id) end local clock = os.clock() - local ok = true + local ok = false local res -- 任务可能在执行过程中被中断,通过close来捕获 local response <close> = function () @@ -140,13 +140,22 @@ function m.doMethod(proto) if ok then m.response(proto.id, res) else - m.responseErr(proto.id, define.ErrorCodes.InternalError, res) + m.responseErr(proto.id, proto._closeReason or define.ErrorCodes.InternalError, res) end end ok, res = xpcall(abil, log.error, proto.params) end) end +function m.close(id, reason) + local proto = m.holdon[id] + if not proto then + return + end + proto._closeReason = reason + await.close('proto:' .. id) +end + function m.doResponse(proto) local id = proto.id local resume = m.waiting[id] |