From 5c4fbc76835f9f31e04b4f99778dea5c63b84d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 23 May 2022 20:14:00 +0800 Subject: fix #1125 --- changelog.md | 1 + script/core/hover/description.lua | 7 +++---- test/crossfile/hover.lua | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 9b202683..097d692b 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,7 @@ ## 3.2.4 * `FIX` hover: can not union `table` with other basic types +* `FIX` [#1125](https://github.com/sumneko/lua-language-server/issues/1125) ## 3.2.3 `2022-5-16` diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua index e9267c0f..712ea1ad 100644 --- a/script/core/hover/description.lua +++ b/script/core/hover/description.lua @@ -229,14 +229,13 @@ local function getBindEnums(source, docGroup) end local function tryDocFieldUpComment(source) - if source.type ~= 'doc.field.name' then + if source.type ~= 'doc.field' then return end - local docField = source.parent - if not docField.bindGroup then + if not source.bindGroup then return end - local comment = getBindComment(docField, docField.bindGroup, docField) + local comment = getBindComment(source, source.bindGroup, source) return comment end diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index 09eceb43..0bf8165b 100644 --- a/test/crossfile/hover.lua +++ b/test/crossfile/hover.lua @@ -1137,3 +1137,24 @@ TEST { (async) (method) C:f(a: any) ```]] } + +TEST { + { + path = 'a.lua', + content = [[ + ---@class Apple + ---The color of your awesome apple! + ---@field color string + local Apple = {} + + Apple. + ]] + }, + hover = [[ +```lua +(field) Apple.color: string +``` + +--- +The color of your awesome apple!]] +} -- cgit v1.2.3