diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-09-23 12:49:15 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-09-23 12:49:15 +0800 |
commit | e88478fa7a42085484d2f9175a720e2a41feb041 (patch) | |
tree | 10a06d3d63bc67492ea4822c1a07899d9219ab9a /server-beta/src | |
parent | 93a19c3772c8f0c0f01c0f9669a3cb0ba7393986 (diff) | |
download | lua-language-server-e88478fa7a42085484d2f9175a720e2a41feb041.zip |
可以跳转局部变量了
Diffstat (limited to 'server-beta/src')
-rw-r--r-- | server-beta/src/files.lua | 3 | ||||
-rw-r--r-- | server-beta/src/proto/interface.lua | 5 | ||||
-rw-r--r-- | server-beta/src/proto/provider.lua | 6 |
3 files changed, 7 insertions, 7 deletions
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 |