-
-
Notifications
You must be signed in to change notification settings - Fork 331
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
base: master
Are you sure you want to change the base?
Conversation
…`---@param a string?Comment` - now its `Comment` instead of `omment`.
Regarding this question, I think it makes sense because it stores the body of a comment 🤔 --foo bar
|
Damn, I found an issues -- length = comment.finish - comment.start
-- length 26, relative finish 19, actual comment.text `-@param a string?Comment` (24 length, without 2)
-- ok
---@param a string?Comment
-- length 27, relative finish 18, actual comment.text `@param a string?Comment` (23 length, without 4!)
-- also real line length 29! `--` token was skipped before "calculating positions"
-- ok comment but wrong colorizing
--[[@param a string?Comment]]
-- also wrong colorizing, so no comment issue
--[[@param a string?]]
-- length 33, relative finish 21, actual comment.text `@param a string?Comment` (23 length, without 10!!!)
-- wrong our offset 2, now comment text is `ment` :<
-- also wrong colorizing
--[===[@param a string[]Comment]===] I could assume to search for the first character Also the expression |
If you believe this PR is still not complete, I think the first thing is to turn it into draft: I will try to respond to the new found issues one by one when I got time 👀 |
the unconsidered
|
local startOffset = comment.start | |
if comment.type == 'comment.long' then | |
startOffset = startOffset + #comment.mark - 2 | |
end |
--[[@param a string?Comment]]
, comment.mark
= [[
=> this is indeed what we need 😄
=> so we can have a generalized form for the conversion functions pair:
local function convertLinePosToCommentPos(comment, linePos)
-- some new comment explaining the new formula
local textOffset = comment.type == 'comment.long' and #comment.mark or 2
return linePos - comment.start + 1 - textOffset
end
local function convertCommentPosToLinePos(comment, commentPos)
-- the reverse of convertLinePosToCommentPos()
local textOffset = comment.type == 'comment.long' and #comment.mark or 2
return commentPos + textOffset - 1 + comment.start
end
With this fix to both convertLinePosToCommentPos
and convertCommentPosToLinePos
, now all comments can be recognized correctly now, including your last test case --[===[@param a string[]Comment]===]
👍
But still the coloring for ?
after string
seems wrong 🤔 and currently I have no idea why.
After some thought, this is not pointless 🤔
If we can be certain that the length of |
The positions were calculated slightly incorrectly there, because it got confused with the lengths.
now its
Comment
instead ofomment
.But I came across the fact that the comment texts
comment.text
do not contain--
at the beginning, because this token is uuuh... being skipped?That is, we were working with a string of a different length and start pos (-2). I made a variable
local textOffset = 2
so that it could be easily fixed in the future.p.s. Maybe you should figure out why this is happening.