Option: Indend Comments active
TSampleClass = class(TObject)
procedure functionx(); { this is multiline comment
---- ----- ---- --------------------------------- -- -------
----------
----
}
procedure functiony(); //test
end;
Expected
TSampleClass = class(TObject)
procedure functionx(); { this is multiline comment
---- ----- ---- --------------------------------- -- -------
----------
----
}
procedure functiony(); //test
end;
That's a really odd one. I don't use this option myself, but I just played a bit with it in the Code Formatter Config window. It definitely doesn't work as expected, e.g.
gets formatted as
And the more spaces I put in front of the first line, the less the following lines get indented. I'm not quite sure how it actually should work.
Last edit: Thomas Mueller 2024-02-25
Actually, it might be working as designed:
The formatter determines the indent of the 2nd and later lines relatively to the first comment line. So given this input:
Since the first line gets indented
So it works as designed for this, trying to keep the relative indentation inside the comment.
Different example:
Output:
Again, this looks just like it should
Would it be possible to create an option that ignores the relative indent for comments and puts everything on one level?
clang format does it job very well in c/c++ context. Maybe the reflow style option would be an possibility.
https://clang.llvm.org/docs/ClangFormatStyleOptions.html#reflowcomments
Example where the comment starts after a procedure like in the original post:
Output:
This looks wrong. I'm not quite sure what to make of this. Maybe I'm interpreting it wrongly. (Remember: I didn't write this code, it was donated to GExperts from the original author Egbert van Nes, so I have to guess what he intended.)
Playing with it a bit further, it turns out that the comments are always indented relativ to the first full comment line, so:
Output:
another example, where it works:
Output
So this seems to be how it is intended to work.
For
i would expect.
Last edit: pustekuchen 2024-02-25
Please give some more examples on how you expect this to work. I'm not sure I understand your request. What is the purpose of the lines in your original report? Are they just place holders for some text? Why do you think the formatting is wrong?
The main problem in my eyes is that if you have a multiline comment that is not indented, it is visually more difficult to distinguish from the next line. In this case the line with "
procedure functiony();".Each comment line (1+) of the multiline comment should start at the same indentation level.
Last edit: pustekuchen 2024-02-25
fixed in revision #5175