diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-20 14:35:36 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-20 14:35:36 +0800 |
commit | 974323b5885b85818c09afeda73e1832a3779d6b (patch) | |
tree | d14cb372e6200a78b58583db5017136e0e309668 | |
parent | 2e6a5507061758113293e4183ddf53a54a4463a4 (diff) | |
download | lua-language-server-974323b5885b85818c09afeda73e1832a3779d6b.zip |
修正来自客户端的 notify 会进行错误回复的bug
-rw-r--r-- | server-beta/src/proto/proto.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/server-beta/src/proto/proto.lua b/server-beta/src/proto/proto.lua index e12631aa..f04653d5 100644 --- a/server-beta/src/proto/proto.lua +++ b/server-beta/src/proto/proto.lua @@ -25,6 +25,10 @@ function m.on(method, callback) end function m.response(id, res) + if id == nil then + log.error('Response id is nil!', util.dump(res)) + return + end -- res 可能是nil,为了转成json时保留nil,使用 container 容器 local data = util.container() data.id = id @@ -35,6 +39,10 @@ function m.response(id, res) end function m.responseErr(id, code, message) + if id == nil then + log.error('Response id is nil!', util.dump(message)) + return + end local buf = jsonrpc.encode { id = id, error = { @@ -88,6 +96,9 @@ function m.doMethod(proto) if passed > 0.2 then log.debug(('Method [%s] takes [%.3f]sec.'):format(method, passed)) end + if not proto.id then + return + end if ok then m.response(proto.id, res) else |