summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-01-07 20:14:14 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-01-07 20:14:14 +0800
commit15a7b101e2556a60288bb8f9066caf132c8cce13 (patch)
treee2d9c3802b71e498f3e6670e78fc4e1355add9fe /script
parent7b73b1e47496b84e41bc10ed9a7d7f0f0d0a80d3 (diff)
downloadlua-language-server-15a7b101e2556a60288bb8f9066caf132c8cce13.zip
fix
Diffstat (limited to 'script')
-rw-r--r--script/core/completion.lua4
-rw-r--r--script/provider/provider.lua12
2 files changed, 9 insertions, 7 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua
index 0762a194..f1bea2e7 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -1272,14 +1272,14 @@ local function getCallEnums(source, index)
if doc.type == 'doc.param'
and doc.param[1] == arg[1] then
local enums = {}
- for _, enum in ipairs(vm.getDocEnums(doc.extends)) do
+ for _, enum in ipairs(vm.getDocEnums(doc.extends) or {}) do
enums[#enums+1] = {
label = enum[1],
description = enum.comment,
kind = define.CompletionItemKind.EnumMember,
}
end
- for _, unit in ipairs(vm.getDocTypeUnits(doc.extends)) do
+ for _, unit in ipairs(vm.getDocTypeUnits(doc.extends) or {}) do
if unit.type == 'doc.type.function' then
local text = files.getText(guide.getUri(unit))
enums[#enums+1] = {
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index 010bc24e..fd8e113c 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -244,11 +244,13 @@ proto.on('textDocument/definition', function (params)
if targetUri then
local targetLines = files.getLines(targetUri)
local targetText = files.getText(targetUri)
- response[i] = define.locationLink(targetUri
- , define.range(targetLines, targetText, info.target.start, info.target.finish)
- , define.range(targetLines, targetText, info.target.start, info.target.finish)
- , define.range(lines, text, info.source.start, info.source.finish)
- )
+ if targetLines then
+ response[i] = define.locationLink(targetUri
+ , define.range(targetLines, targetText, info.target.start, info.target.finish)
+ , define.range(targetLines, targetText, info.target.start, info.target.finish)
+ , define.range(lines, text, info.source.start, info.source.finish)
+ )
+ end
end
end
return response