diff options
-rw-r--r-- | script/core/hover/description.lua | 16 | ||||
-rw-r--r-- | test/crossfile/hover.lua | 26 |
2 files changed, 38 insertions, 4 deletions
diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua index 32a0a798..e32d204c 100644 --- a/script/core/hover/description.lua +++ b/script/core/hover/description.lua @@ -349,15 +349,23 @@ local function getFunctionComment(source) end local function tryDocComment(source) + local md = markdown() if source.type == 'function' then local comment = getFunctionComment(source) - if comment then - return comment - end + md:add('md', comment) source = source.parent end local comment = lookUpDocComments(source) - return comment + md:add('md', comment) + if source.type == 'doc.alias' then + local enums = buildEnumChunk(source, source.alias[1], guide.getUri(source)) + md:add('lua', enums) + end + local result = md:string() + if result == '' then + return nil + end + return result end local function tryDocOverloadToComment(source) diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index f412183c..60a962e9 100644 --- a/test/crossfile/hover.lua +++ b/test/crossfile/hover.lua @@ -1471,3 +1471,29 @@ function A() comments]] } + +TEST { + { + path = 'a.lua', + content = [[ + ---@alias A + ---| 1 # comment1 + ---| 2 # comment2 + + ---@type A + local <?x?> + ]] + }, + hover = [[ +```lua +local x: 1|2 +``` + +--- + +```lua +A: + | 1 -- comment1 + | 2 -- comment2 +```]] +} |