Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LuaDoc. Fixed the start position of the comment first symbol in docs #3028

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
```
* `NEW` Test CLI: `--name=<testname>` `-n=<testname>`: run specify unit test
* `FIX` Fixed the error that the configuration file pointed to by the `--configpath` option was not read and loaded.
* `FIX` Fixed the start position of the comment first symbol in docs `---@param a string?Comment` - now its `Comment` instead of `omment`.

## 3.13.5
`2024-12-20`
Expand Down
10 changes: 7 additions & 3 deletions script/parser/luadoc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1743,11 +1743,15 @@ local function buildLuaDoc(comment)
finish = rest.firstFinish or result.finish
end
end
local cstart = text:find('%S', finish - comment.start)
if cstart and cstart < comment.finish then
-- the subtraction is the length of the skipped string, so the start position is `+ 1`
local cpos = finish - comment.start + 1
-- actual text start is `comment.start + 2` because of `--` for some reason
local textOffset = 2
local cstart = text:find('%S', cpos - textOffset)
TIMONz1535 marked this conversation as resolved.
Show resolved Hide resolved
if cstart and cstart < comment.finish - textOffset then
result.comment = {
type = 'doc.tailcomment',
start = cstart + comment.start,
start = comment.start + cstart - 1 + textOffset,
finish = comment.finish,
parent = result,
text = trimTailComment(text:sub(cstart)),
Expand Down
Loading