From eb7c7b6dcae752b03332f4f6d9004381eb87d457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Thu, 10 Jan 2019 09:16:59 +0800 Subject: =?UTF-8?q?=E5=88=A4=E4=B8=AA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/method/textDocument/definition.lua | 32 ++++++++++++++------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'server/src/method/textDocument/definition.lua') 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 -- cgit v1.2.3