diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-01-30 17:00:24 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-01-30 17:00:24 +0800 |
commit | bd7fe18fc77e3f443de7b47673b1afddcc4c70f4 (patch) | |
tree | 2701f97397430a882fc5c218592eb68c59ee9632 /server/src/method | |
parent | cc2a431932e77236606d184c704f0ae49462d8d2 (diff) | |
download | lua-language-server-bd7fe18fc77e3f443de7b47673b1afddcc4c70f4.zip |
修正换算错误的问题
Diffstat (limited to 'server/src/method')
-rw-r--r-- | server/src/method/textDocument/references.lua | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/server/src/method/textDocument/references.lua b/server/src/method/textDocument/references.lua index 47f7b370..ee7fa80c 100644 --- a/server/src/method/textDocument/references.lua +++ b/server/src/method/textDocument/references.lua @@ -17,23 +17,26 @@ return function (lsp, params) local locations = {} for i, position in ipairs(positions) do - local start, finish, uri = position[1], position[2], position[3] - local start_row, start_col = lines:rowcol(start) - local finish_row, finish_col = lines:rowcol(finish) - locations[i] = { - uri = uri, - range = { - start = { - line = start_row - 1, - character = start_col - 1, - }, - ['end'] = { - line = finish_row - 1, - -- 这里不用-1,因为前端期待的是匹配完成后的位置 - character = finish_col, - }, + local start, finish, valueUri = position[1], position[2], (position[3] or uri) + local _, valueLines = lsp:loadVM(valueUri) + if valueLines then + local start_row, start_col = valueLines:rowcol(start) + local finish_row, finish_col = valueLines:rowcol(finish) + locations[i] = { + uri = valueUri, + range = { + start = { + line = start_row - 1, + character = start_col - 1, + }, + ['end'] = { + line = finish_row - 1, + -- 这里不用-1,因为前端期待的是匹配完成后的位置 + character = finish_col, + }, + } } - } + end end local response = locations |