summaryrefslogtreecommitdiff
path: root/server/src/method
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-01-10 09:16:59 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-01-10 09:16:59 +0800
commiteb7c7b6dcae752b03332f4f6d9004381eb87d457 (patch)
treeee5c9c81d3575dd18be402abd51cdf316b72866d /server/src/method
parentdb88a4edc504f498d8488a777249f4b13a634188 (diff)
downloadlua-language-server-eb7c7b6dcae752b03332f4f6d9004381eb87d457.zip
判个空
Diffstat (limited to 'server/src/method')
-rw-r--r--server/src/method/textDocument/definition.lua32
-rw-r--r--server/src/method/textDocument/implementation.lua32
2 files changed, 34 insertions, 30 deletions
diff --git a/server/src/method/textDocument/definition.lua b/server/src/method/textDocument/definition.lua
index 60e6bb1e..a9f92631 100644
--- a/server/src/method/textDocument/definition.lua
+++ b/server/src/method/textDocument/definition.lua
@@ -40,22 +40,24 @@ return function (lsp, params)
for i, position in ipairs(positions) do
local start, finish, valueUri = position[1], position[2], (position[3] or uri)
local _, valueLines = lsp:loadVM(valueUri)
- 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,
- },
+ 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
diff --git a/server/src/method/textDocument/implementation.lua b/server/src/method/textDocument/implementation.lua
index 4c7dfb3a..df6f027b 100644
--- a/server/src/method/textDocument/implementation.lua
+++ b/server/src/method/textDocument/implementation.lua
@@ -37,22 +37,24 @@ return function (lsp, params)
for i, position in ipairs(positions) do
local start, finish, valueUri = position[1], position[2], (position[3] or uri)
local _, valueLines = lsp:loadVM(valueUri)
- 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,
- },
+ 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