summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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