summaryrefslogtreecommitdiff
path: root/script-beta
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-11-03 11:04:21 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-11-03 11:04:21 +0800
commit116b62f42dc78b2f6559e7d22b9f59741f15db54 (patch)
tree8775084cf033adcc5ecaea9ac7e5a2f53415fd5f /script-beta
parent5c566b1c4124b256bac2fbfe99444533350115de (diff)
downloadlua-language-server-116b62f42dc78b2f6559e7d22b9f59741f15db54.zip
修正服务关闭时的报错
Diffstat (limited to 'script-beta')
-rw-r--r--script-beta/jsonrpc.lua23
1 files changed, 12 insertions, 11 deletions
diff --git a/script-beta/jsonrpc.lua b/script-beta/jsonrpc.lua
index 5957588f..d0befd5b 100644
--- a/script-beta/jsonrpc.lua
+++ b/script-beta/jsonrpc.lua
@@ -20,20 +20,21 @@ local function readProtoHead(reader, errHandle)
local head = {}
while true do
local line = reader 'L'
+ if line == nil then
+ break
+ end
if line == '\r\n' then
break
- else
- local k, v = line:match '^([^:]+)%s*%:%s*(.+)\r\n$'
- if k then
- if k == 'Content-Length' then
- v = tonumber(v)
- end
- head[k] = v
- else
- errHandle('Proto header error:', head)
- break
- end
end
+ local k, v = line:match '^([^:]+)%s*%:%s*(.+)\r\n$'
+ if not k then
+ errHandle('Proto header error:', head)
+ break
+ end
+ if k == 'Content-Length' then
+ v = tonumber(v)
+ end
+ head[k] = v
end
return head
end