diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-09-23 18:59:57 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-09-23 18:59:57 +0800 |
commit | 4e1937f19ed61d3e7163aa06e267f3e92489e321 (patch) | |
tree | acbdea488c5ab38db080d2ff44360e4611f1dbbd /server-beta/src | |
parent | 7e9154e64d2a743903b1f9400bd254a039816ca0 (diff) | |
download | lua-language-server-4e1937f19ed61d3e7163aa06e267f3e92489e321.zip |
修正一些报错
Diffstat (limited to 'server-beta/src')
-rw-r--r-- | server-beta/src/files.lua | 6 | ||||
-rw-r--r-- | server-beta/src/proto/provider.lua | 3 | ||||
-rw-r--r-- | server-beta/src/pub/pub.lua | 2 | ||||
-rw-r--r-- | server-beta/src/task.lua | 5 |
4 files changed, 12 insertions, 4 deletions
diff --git a/server-beta/src/files.lua b/server-beta/src/files.lua index 0d8bd526..15190630 100644 --- a/server-beta/src/files.lua +++ b/server-beta/src/files.lua @@ -41,9 +41,11 @@ function m.setText(uri, text) pub.removeTask(file.compiling) end file.compiling = pub.syncTask('compile', text, function (ast) - ast.uri = originUri - file.ast = ast file.compiling = nil + file.ast = ast + if ast then + ast.uri = originUri + end local onCompiledList = file.onCompiledList if onCompiledList then file.onCompiledList = nil diff --git a/server-beta/src/proto/provider.lua b/server-beta/src/proto/provider.lua index 3e89a50c..01121a15 100644 --- a/server-beta/src/proto/provider.lua +++ b/server-beta/src/proto/provider.lua @@ -68,6 +68,9 @@ proto.on('textDocument/definition', function (params) local core = require 'core.definition' local uri = params.textDocument.uri local ast = files.getAst(uri) + if not ast then + return nil + end local text = files.getText(uri) local offset = inte.offset(ast.lines, text, params.position) local result = core(ast, text, offset) diff --git a/server-beta/src/pub/pub.lua b/server-beta/src/pub/pub.lua index f5ed9e8f..b077ad9f 100644 --- a/server-beta/src/pub/pub.lua +++ b/server-beta/src/pub/pub.lua @@ -90,7 +90,7 @@ function m.popTask(brave, id, result) m.checkWaitingTask(brave) if not info.removed then info.removed = true - info.callback(result) + xpcall(info.callback, log.error, result) end end diff --git a/server-beta/src/task.lua b/server-beta/src/task.lua index 9219a6a2..5b7fb8dd 100644 --- a/server-beta/src/task.lua +++ b/server-beta/src/task.lua @@ -13,7 +13,10 @@ end --- 创建一个任务 function m.create(callback) local co = coroutine.create(callback) - coroutine.resume(co) + local suc, err = coroutine.resume(co) + if not suc and m.errHandle then + m.errHandle(debug.traceback(co, err)) + end end --- 休眠一段时间 |