Skip to content

Commit cbe45e1

Browse files
committed
#3028. Fix incorrect rest.range and finish on multiline types. Do not try to process a multiline result, while doc is the first line.
1 parent 9ba27a6 commit cbe45e1

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

script/parser/luadoc.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,10 +1739,16 @@ local function buildLuaDoc(comment)
17391739
local finish = result.firstFinish or result.finish
17401740
if rests then
17411741
for _, rest in ipairs(rests) do
1742-
rest.range = comment.finish
1743-
finish = rest.firstFinish or result.finish
1742+
rest.range = math.max(comment.finish, rest.finish)
1743+
finish = rest.firstFinish or rest.finish
17441744
end
17451745
end
1746+
1747+
-- `result` can be a multiline annotation or an alias, while `doc` is the first line, so we can't parse comment
1748+
if finish >= comment.finish then
1749+
return result, rests
1750+
end
1751+
17461752
local cstart = doc:find('%S', finish - startOffset)
17471753
if cstart then
17481754
result.comment = {
@@ -1758,9 +1764,7 @@ local function buildLuaDoc(comment)
17581764
end
17591765
end
17601766
end
1761-
end
17621767

1763-
if result then
17641768
return result, rests
17651769
end
17661770

0 commit comments

Comments
 (0)