Skip to content

Commit 7d546ae

Browse files
committed
resolve #1230
show enums for variables
1 parent 82d716c commit 7d546ae

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

script/core/hover/description.lua

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,15 +349,23 @@ local function getFunctionComment(source)
349349
end
350350

351351
local function tryDocComment(source)
352+
local md = markdown()
352353
if source.type == 'function' then
353354
local comment = getFunctionComment(source)
354-
if comment then
355-
return comment
356-
end
355+
md:add('md', comment)
357356
source = source.parent
358357
end
359358
local comment = lookUpDocComments(source)
360-
return comment
359+
md:add('md', comment)
360+
if source.type == 'doc.alias' then
361+
local enums = buildEnumChunk(source, source.alias[1], guide.getUri(source))
362+
md:add('lua', enums)
363+
end
364+
local result = md:string()
365+
if result == '' then
366+
return nil
367+
end
368+
return result
361369
end
362370

363371
local function tryDocOverloadToComment(source)

test/crossfile/hover.lua

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,3 +1471,29 @@ function A()
14711471
14721472
comments]]
14731473
}
1474+
1475+
TEST {
1476+
{
1477+
path = 'a.lua',
1478+
content = [[
1479+
---@alias A
1480+
---| 1 # comment1
1481+
---| 2 # comment2
1482+
1483+
---@type A
1484+
local <?x?>
1485+
]]
1486+
},
1487+
hover = [[
1488+
```lua
1489+
local x: 1|2
1490+
```
1491+
1492+
---
1493+
1494+
```lua
1495+
A:
1496+
| 1 -- comment1
1497+
| 2 -- comment2
1498+
```]]
1499+
}

0 commit comments

Comments
 (0)