LuaDoc. Fixed the start position of the comment first symbol in docs#3028
LuaDoc. Fixed the start position of the comment first symbol in docs#3028sumneko merged 4 commits intoLuaLS:masterfrom
Conversation
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
|
After some thought, this is not pointless 🤔
If we can be certain that the length of |
…dLuaDoc, sync with semantic logic. Fix crash 'comment.clong' type for /*, fix typo docGeneric.
…o not try to process a multiline `result`, while `doc` is the first line.
…(pattern is optional)
537aaed to
4af79e3
Compare
|
I have redone this.
Actually we call lua-language-server/script/parser/luadoc.lua Lines 1716 to 1736 in 9ba27a6 The startOffset for the comment.shortThe In Later I discovered exactly the same logic in the lua-language-server/script/core/semantic-tokens.lua Lines 906 to 924 in 9ba27a6
The old one implied that the
--[===[ @param a string?ComMMS1]===]
local function new(a) endThis pattern is optional My complete test---@type integer, string, string Comment
local a, b, c
---@param a string?Comment
local function new(a) end
--- @param a string?ComSpa1
local function new(a) end
---@ param a string?ComSpa2
local function new(a) end
--- @ param a string?ComSpa3
local function new(a) end
--[[@param a string?ComMult]]
local function new(a) end
--[[ @param a string?ComMuS1]]
local function new(a) end
--[[@ param a string?ComMuS2]]
local function new(a) end
--[[ @ param a string?ComMuS3]]
local function new(a) end
--[===[@param a string?ComMMul]===]
local function new(a) end
--[===[ @param a string?ComMMS1]===]
local function new(a) end
--[===[@ param a string?ComMMS2]===]
local function new(a) end
--[===[ @ param a string?ComMMS3]===]
local function new(a) end
--- @param a string?
local function new(a) end
--[[ @param a string? ]]
local function new(a) end
--[===[ @param a string? ]===]
local function new(a) end
--- @param a string? A
local function new(a) end
--[[ @param a string? B]]
local function new(a) end
--[===[ @param a string? C]===]
local function new(a) endResult |
No, this is a potential support if the bug is resolved in the future (it will work automatically). But if is not, it does not affect anything. Actually the pattern for short already contained optional spaces, but not for long ones. I did for the long ones as well. |
|
@tomlau10 can I just add This will eliminate the ambiguity, and we will no longer keep the lua-language-server/script/parser/compile.lua Lines 578 to 597 in 9ba27a6 |
I don't think so 😕 lua-language-server/script/parser/luadoc.lua Lines 697 to 719 in cb964c6 Back to comment, for short comment there is no mark concept, as nothing is used to quote the comment body. Maybe you can just keep this PR as is. |
|
非常感谢你们的工作!请问这个PR已经准备好合并了吗? |
Thank you so much for your work! Is this PR ready to be merged? |
Yes. My latest changes is #3028 (comment) |


The positions were calculated slightly incorrectly there, because it got confused with the lengths.now its
Commentinstead ofomment.But I came across the fact that the comment textscomment.textdo 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 variablelocal textOffset = 2so that it could be easily fixed in the future.p.s. Maybe you should figure out why this is happening.upd. Please see the latest message for actual changes #3028 (comment)