Skip to content

Commit 88c252c

Browse files
committed
LuaDoc. Fixed the start position of the comment first symbol in docs ---@param a string?Comment - now its Comment instead of omment.
1 parent cb964c6 commit 88c252c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
```
1414
* `NEW` Test CLI: `--name=<testname>` `-n=<testname>`: run specify unit test
1515
* `FIX` Fixed the error that the configuration file pointed to by the `--configpath` option was not read and loaded.
16+
* `FIX` Fixed the start position of the comment first symbol in docs `---@param a string?Comment` - now its `Comment` instead of `omment`.
1617

1718
## 3.13.5
1819
`2024-12-20`

script/parser/luadoc.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,11 +1743,15 @@ local function buildLuaDoc(comment)
17431743
finish = rest.firstFinish or result.finish
17441744
end
17451745
end
1746-
local cstart = text:find('%S', finish - comment.start)
1747-
if cstart and cstart < comment.finish then
1746+
-- the subtraction is the length of the skipped string, so the start position is `+ 1`
1747+
local cpos = finish - comment.start + 1
1748+
-- actual text start is `comment.start + 2` because of `--` for some reason
1749+
local textOffset = 2
1750+
local cstart = text:find('%S', cpos - textOffset)
1751+
if cstart and cstart < comment.finish - textOffset then
17481752
result.comment = {
17491753
type = 'doc.tailcomment',
1750-
start = cstart + comment.start,
1754+
start = comment.start + cstart - 1 + textOffset,
17511755
finish = comment.finish,
17521756
parent = result,
17531757
text = trimTailComment(text:sub(cstart)),

0 commit comments

Comments
 (0)