From aa669fd32b51f338dfc76e8efd40ade98431537b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Sat, 27 Mar 2021 17:39:08 +0800 Subject: fix #468 --- changelog.md | 3 +++ script/core/hover/description.lua | 3 +++ test/crossfile/hover.lua | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/changelog.md b/changelog.md index d82b97b9..6ccdb225 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ # changelog +## 1.20.1 +* `FIX` [#468](https://github.com/sumneko/lua-language-server/issues/468) + ## 1.20.0 `2021-3-27` * `CHG` telemetry: change to opt-in, see [#462](https://github.com/sumneko/lua-language-server/issues/462) and [Privacy-Policy](https://github.com/sumneko/lua-language-server/wiki/Privacy-Policy) diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua index d081aa7f..3766d2f4 100644 --- a/script/core/hover/description.lua +++ b/script/core/hover/description.lua @@ -358,6 +358,9 @@ return function (source) if source.type == 'string' then return asString(source) end + if source.type == 'field' then + source = source.parent + end return tryDocOverloadToComment(source) or tryDocFieldUpComment(source) or tyrDocParamComment(source) diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index b72a6391..d0080ed9 100644 --- a/test/crossfile/hover.lua +++ b/test/crossfile/hover.lua @@ -684,3 +684,35 @@ hover = { name = 'x', description = 'BBB' }} + +TEST {{ path = 'a.lua', content = '', }, { + path = 'b.lua', + content = [[ +---AAA +G. = 1 + +---BBB +G.A = 1 + ]] +}, +hover = { + label = 'global G.A: integer = 1', + name = 'G.A', + description = 'AAA' +}} + +TEST {{ path = 'a.lua', content = '', }, { + path = 'b.lua', + content = [[ +---AAA +G.A = 1 + +---BBB +G. = 1 + ]] +}, +hover = { + label = 'global G.A: integer = 1', + name = 'G.A', + description = 'BBB' +}} -- cgit v1.2.3