summaryrefslogtreecommitdiff
path: root/script-beta/core/hover
diff options
context:
space:
mode:
Diffstat (limited to 'script-beta/core/hover')
-rw-r--r--script-beta/core/hover/arg.lua6
-rw-r--r--script-beta/core/hover/name.lua1
-rw-r--r--script-beta/core/hover/return.lua5
3 files changed, 10 insertions, 2 deletions
diff --git a/script-beta/core/hover/arg.lua b/script-beta/core/hover/arg.lua
index 5dcf94b6..ef5eef57 100644
--- a/script-beta/core/hover/arg.lua
+++ b/script-beta/core/hover/arg.lua
@@ -90,7 +90,11 @@ local function asDocFunction(source)
for i = 1, #source.args do
local arg = source.args[i]
local name = arg.name[1]
- args[i] = ('%s: %s'):format(name, vm.getInferType(arg.extends))
+ args[i] = ('%s: %s%s'):format(
+ name,
+ vm.getInferType(arg.extends),
+ arg.optional and '?' or ''
+ )
end
return table.concat(args, ', ')
end
diff --git a/script-beta/core/hover/name.lua b/script-beta/core/hover/name.lua
index 4d5b015c..9f19d8f3 100644
--- a/script-beta/core/hover/name.lua
+++ b/script-beta/core/hover/name.lua
@@ -71,6 +71,7 @@ end
local function asDocFunction(source)
local doc = guide.getParentType(source, 'doc.type')
+ or guide.getParentType(source, 'doc.overload')
if not doc or not doc.bindSources then
return ''
end
diff --git a/script-beta/core/hover/return.lua b/script-beta/core/hover/return.lua
index 4159e039..a0b4363d 100644
--- a/script-beta/core/hover/return.lua
+++ b/script-beta/core/hover/return.lua
@@ -126,7 +126,10 @@ local function asDocFunction(source)
end
local returns = {}
for i, rtn in ipairs(source.returns) do
- local rtnText = vm.getInferType(rtn)
+ local rtnText = ('%s%s'):format(
+ vm.getInferType(rtn),
+ rtn.optional and '?' or ''
+ )
if i == 1 then
returns[#returns+1] = (' -> %s'):format(rtnText)
else