From e88478fa7a42085484d2f9175a720e2a41feb041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 23 Sep 2019 12:49:15 +0800 Subject: =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E8=B7=B3=E8=BD=AC=E5=B1=80=E9=83=A8?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-beta/src/files.lua | 3 ++- server-beta/src/proto/interface.lua | 5 ++--- server-beta/src/proto/provider.lua | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'server-beta/src') diff --git a/server-beta/src/files.lua b/server-beta/src/files.lua index 7d1fe0da..0d8bd526 100644 --- a/server-beta/src/files.lua +++ b/server-beta/src/files.lua @@ -25,6 +25,7 @@ end --- 设置文件文本 function m.setText(uri, text) + local originUri = uri if platform.OS == 'Windows' then uri = uri:lower() end @@ -40,7 +41,7 @@ function m.setText(uri, text) pub.removeTask(file.compiling) end file.compiling = pub.syncTask('compile', text, function (ast) - ast.uri = uri + ast.uri = originUri file.ast = ast file.compiling = nil local onCompiledList = file.onCompiledList diff --git a/server-beta/src/proto/interface.lua b/server-beta/src/proto/interface.lua index ddba623a..6af0c996 100644 --- a/server-beta/src/proto/interface.lua +++ b/server-beta/src/proto/interface.lua @@ -11,8 +11,7 @@ local m = {} function m.offset(lines, text, position) local row = position.line local start = guide.lineRange(lines, row) - local col = utf8.offset(text, position.character + 1, start) - local offset = guide.offsetOf(lines, row, col) + local offset = utf8.offset(text, position.character + 1, start) return offset end @@ -25,7 +24,7 @@ end function m.position(lines, text, offset) local row, col = guide.positionOf(lines, offset) local start = guide.lineRange(lines, row) - local ucol = utf8.len(text, start + 1, col, true) + local ucol = utf8.len(text, start + 1, start + col, true) return { line = row, character = ucol, diff --git a/server-beta/src/proto/provider.lua b/server-beta/src/proto/provider.lua index 9e3fe019..38428362 100644 --- a/server-beta/src/proto/provider.lua +++ b/server-beta/src/proto/provider.lua @@ -71,9 +71,9 @@ proto.on('textDocument/definition', function (params) local response = {} for i, info in ipairs(result) do response[i] = inte.locationLink(info.uri - , inte.range(ast.lines, text, info.target.start, info.target.finish) - , inte.range(ast.lines, text, info.target.start, info.target.finish) - , inte.range(ast.lines, text, info.source.start, info.source.finish) + , inte.range(ast.lines, text, info.target.start - 1, info.target.finish) + , inte.range(ast.lines, text, info.target.start - 1, info.target.finish) + , inte.range(ast.lines, text, info.source.start - 1, info.source.finish) ) end return response -- cgit v1.2.3