diff options
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/parser/luadoc.lua | 4 | ||||
-rw-r--r-- | test/crossfile/hover.lua | 22 |
3 files changed, 26 insertions, 1 deletions
diff --git a/changelog.md b/changelog.md index 8cf548d5..e509505e 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,7 @@ * `CHG` rename `table*` to `tablelib` * `FIX` missed syntax error `f() = 1` * `FIX` missed global `bit` in `LuaJIT` +* `FIX` [#349](https://github.com/sumneko/lua-language-server/issues/349) ## 1.15.1 `2021-2-18` diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index fa1cc38b..78fcf8f7 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -530,6 +530,7 @@ function parseType(parent) nextToken() end result.finish = getFinish() + result.firstFinish = result.finish while true do local nextComm = NextComment('peek') @@ -615,6 +616,7 @@ local function parseParam() return result end result.finish = getFinish() + result.firstFinish = result.extends.firstFinish return result end @@ -932,7 +934,7 @@ local function buildLuaDoc(comment) local result = convertTokens() if result then result.range = comment.finish - local cstart = text:find('%S', result.finish - comment.start + 2) + local cstart = text:find('%S', (result.firstFinish or result.finish) - comment.start + 2) if cstart and cstart < comment.finish then result.comment = { type = 'doc.tailcomment', diff --git a/test/crossfile/hover.lua b/test/crossfile/hover.lua index 20a44d96..5995f1bd 100644 --- a/test/crossfile/hover.lua +++ b/test/crossfile/hover.lua @@ -613,3 +613,25 @@ comment1 comment2]] }} + +TEST {{ path = 'a.lua', content = '', }, { + path = 'b.lua', + content = [[ + ---@param a boolean # xxx + ---| 'true' # ttt + ---| 'false' # fff + local function <?f?>(a) + end + ]] +}, +hover = { + label = "function f(a: boolean|true|false)", + name = 'f', + description = [[ +@*param* `a` — xxx +```lua +a: boolean + | true -- ttt + | false -- fff +```]] +}} |