Enabling line breaks before the comma for uses lists will comment out the unit names if the line before them had a comment. This ...
uses
Windows, // comment1
SysUtils, // comment2
Classes, // comment3
Graphics, // comment4
Forms; // comment5
... gets formatted as this ...
uses
Windows
, // comment1SysUtils
, // comment2Classes
, // comment3Graphics
, // comment4Forms
; // comment5
The culprit is the combination of the two Line Breaks options
I think the preferred way to format
would be
I will take a look at this.
Last edit: Christoph "baka0815" Schwerdtfeger 2025-08-15
Here is a patch for the formatter.
And here the patch for the unit tests.
The patch seems to fix the bug. But the output is not what you proposed above. It looks like this:
but you suggested this:
The difference is the indentation of the comma.
Since I don't use that kind of formatting, I don't really care that much either way. So if you are happy with it, I'll accept it.
Regarding the code I saw that you introduced a rather generically named variable which I don't like. But I will need to have a closer look.
Edit: What about moving the whole code block handling the rtComma case to a function that returns True if CheckIndent should be exited? That would allow to remove the additional variable and make the code a bit more readable. (I don't like that huge case statement anyway, but never could be bothered to break it up.)
Last edit: Thomas Mueller 2025-08-16
That depends on the settings (see
TestDoNotIndentUsesStartingWithComma1Commentvs.TestIndentUsesComment:vs.
That is something I will look at.
Last edit: Christoph "baka0815" Schwerdtfeger 2025-08-18
Would it be ok, if I change that in the other patch-set ( https://sourceforge.net/p/gexperts/feature-requests/198/ )?
Last edit: Christoph "baka0815" Schwerdtfeger 2025-08-18
Yes, do that. (Sorry for taking so long to answer, I haven't got much time currently.) This will hopefully get better next week.
The
rather generically named variablewould beIdxChanged, right?This could be named
TokenIndexChangedor similar, if you prefer.Are there other things missing or in need of change?
Last edit: Christoph "baka0815" Schwerdtfeger 2025-08-25
Yes, IdxChanged was the variable I was referring to. But if you move the code to a separate method, you don't need to change the variable name because it will be local to the new method.
The rest should be fine.
patch applied in revision #4864