summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md1
-rw-r--r--script/core/hover/description.lua20
-rw-r--r--test/crossfile/hover.lua31
3 files changed, 48 insertions, 4 deletions
diff --git a/changelog.md b/changelog.md
index 1c5d74f7..492e79cc 100644
--- a/changelog.md
+++ b/changelog.md
@@ -7,6 +7,7 @@
+ `Lua.completion.showWord`
+ `Lua.completion.requireSeparator`
* `CHG` hover: improve showing multi defines
+* `CHG` hover: improve showing multi comments at enums
* `CHG` hint: `Lua.hint.paramName` now supports `Disable`, `Literal` and `All`
* `CHG` no longer ignore file names case in Windows
* `CHG` watching library changes
diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua
index 9ec5cd72..fc220c74 100644
--- a/script/core/hover/description.lua
+++ b/script/core/hover/description.lua
@@ -166,13 +166,25 @@ local function buildEnumChunk(docType, name)
end
lines[#lines+1] = ('%s: %s'):format(name, table.concat(types))
for _, enum in ipairs(enums) do
- lines[#lines+1] = (' %s %s%s'):format(
- (enum.default and '->')
+ local enumDes = (' %s %s'):format(
+ (enum.default and '->')
or (enum.additional and '+>')
or ' |',
- enum[1],
- enum.comment and (' -- %s'):format(enum.comment) or ''
+ enum[1]
)
+ if enum.comment then
+ local first = true
+ local len = #enumDes
+ for comm in enum.comment:gmatch '[^\r\n]+' do
+ if first then
+ first = false
+ enumDes = ('%s -- %s'):format(enumDes, comm)
+ else
+ enumDes = ('%s\n%s -- %s'):format(enumDes, (' '):rep(len), comm)
+ end
+ end
+ end
+ lines[#lines+1] = enumDes
end
return table.concat(lines, '\n')
end
diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua
index 2ceeb597..a877d226 100644
--- a/test/crossfile/hover.lua
+++ b/test/crossfile/hover.lua
@@ -954,3 +954,34 @@ local t: string|fun():string
function t()
-> string
```]]}
+
+TEST {{ path = 'a.lua', content = '', }, {
+ path = 'b.lua',
+ content = [[
+---@alias T
+---comment 1
+---comment 2
+---| 'a'
+---comment 3
+---comment 4
+---| 'b'
+
+---@param p T
+local function <?f?>(p)
+end
+]]
+},
+hover = [[
+```lua
+function f(p: a|b)
+```
+
+---
+
+```lua
+p: T
+ | a -- comment 1
+ -- comment 2
+ | b -- comment 3
+ -- comment 4
+```]]}