diff options
-rw-r--r-- | server/locale/en-US/script.lni | 1 | ||||
-rw-r--r-- | server/locale/zh-CN/script.lni | 1 | ||||
-rw-r--r-- | server/src/method/textDocument/publishDiagnostics.lua | 17 |
3 files changed, 16 insertions, 3 deletions
diff --git a/server/locale/en-US/script.lni b/server/locale/en-US/script.lni index 2b14012f..42bb683a 100644 --- a/server/locale/en-US/script.lni +++ b/server/locale/en-US/script.lni @@ -14,3 +14,4 @@ MWS_NOT_COMPLETE = 'Workspace is not complete yet. You may try again later. MWS_COMPLETE = 'Workspace is complete now. You may try again...' PARSER_CRASH = 'Parser crashed! Last words:{}' +PARSER_IN_DEVELOPMENT = 'Syntax check is still in TODO...' diff --git a/server/locale/zh-CN/script.lni b/server/locale/zh-CN/script.lni index 17b0948d..300e8cc7 100644 --- a/server/locale/zh-CN/script.lni +++ b/server/locale/zh-CN/script.lni @@ -14,3 +14,4 @@ MWS_NOT_COMPLETE = '工作目录还没有准备好,你可以稍后再试 MWS_COMPLETE = '工作目录准备好了,你可以再试一下了...' PARSER_CRASH = '语法解析崩溃了!遗言:{}' +PARSER_IN_DEVELOPMENT = '语法检查还在TODO列表里...' diff --git a/server/src/method/textDocument/publishDiagnostics.lua b/server/src/method/textDocument/publishDiagnostics.lua index 1186374d..552a4ca7 100644 --- a/server/src/method/textDocument/publishDiagnostics.lua +++ b/server/src/method/textDocument/publishDiagnostics.lua @@ -1,4 +1,5 @@ local matcher = require 'matcher' +local lang = require 'language' local DiagnosticSeverity = { Error = 1, @@ -78,15 +79,25 @@ end local function buildError(err, lines) local diagnostic = { source = 'Lua Language Server', - message = 'Error', + message = lang.script.PARSER_IN_DEVELOPMENT, } if err.level == 'error' then diagnostic.severity = DiagnosticSeverity.Error else diagnostic.severity = DiagnosticSeverity.Warning end - local range = getRange(err.pos, err.pos, lines) - range['end'].character = 9999 + local row, col = lines:rowcol(err.pos) + local _, max = lines:range(row) + local range = { + start = { + line = row - 1, + character = col - 1, + }, + ['end'] = { + line = row - 1, + character = max, + }, + } diagnostic.range = range return diagnostic end |