summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-11-16 15:51:00 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-11-18 17:10:37 +0800
commitab66ba1271153ae9113749ac12aa59f01dd51f48 (patch)
treedc681c4e5d7242b312f829b1a719c068aaee6e78 /script
parent4f67a3a783ca55c28d23eb29a5b7089cbcab7625 (diff)
downloadlua-language-server-ab66ba1271153ae9113749ac12aa59f01dd51f48.zip
`Lua.IntelliSense.traceReturn`
Diffstat (limited to 'script')
-rw-r--r--script/config/config.lua1
-rw-r--r--script/core/noder.lua4
-rw-r--r--script/core/searcher.lua17
3 files changed, 21 insertions, 1 deletions
diff --git a/script/config/config.lua b/script/config/config.lua
index 42a9587d..869d1f0f 100644
--- a/script/config/config.lua
+++ b/script/config/config.lua
@@ -201,6 +201,7 @@ local Template = {
['Lua.window.statusBar'] = Type.Boolean >> true,
['Lua.window.progressBar'] = Type.Boolean >> true,
['Lua.IntelliSense.localSet'] = Type.Boolean >> false,
+ ['Lua.IntelliSense.traceReturn'] = Type.Boolean >> false,
['Lua.telemetry.enable'] = Type.Or(Type.Boolean >> false, Type.Nil),
['files.associations'] = Type.Hash(Type.String, Type.String),
['files.exclude'] = Type.Hash(Type.String, Type.Boolean),
diff --git a/script/core/noder.lua b/script/core/noder.lua
index 1aeb2f61..90f92599 100644
--- a/script/core/noder.lua
+++ b/script/core/noder.lua
@@ -1320,7 +1320,9 @@ compileNodeMap = util.switch()
, index
)
pushForward(noders, returnID, getID(rtnObj))
- pushBackward(noders, getID(rtnObj), returnID, INFO_DEEP_AND_DONT_CROSS)
+ if config.get 'Lua.IntelliSense.traceReturn' then
+ pushBackward(noders, getID(rtnObj), returnID, INFO_DEEP_AND_DONT_CROSS)
+ end
end
end
end
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index 3c210b1b..f2b9b291 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -17,6 +17,7 @@ local next = next
local error = error
local type = type
local setmetatable = setmetatable
+local ipairs = ipairs
local tconcat = table.concat
local ssub = string.sub
local sfind = string.find
@@ -975,6 +976,22 @@ local function prepareSearch(source)
end
local uri = getUri(source)
local id = getID(source)
+ -- return function
+ if source.type == 'function' and source.parent.type == 'return' then
+ local func = guide.getParentFunction(source)
+ if func.type == 'function' then
+ for index, rtn in ipairs(source.parent) do
+ if rtn == source then
+ id = sformat('%s%s%s'
+ , getID(func)
+ , RETURN_INDEX
+ , index
+ )
+ break
+ end
+ end
+ end
+ end
return uri, id
end