Toad World® Forums

Code formater indents comments each time the code is formatted

I've the following sample SELECT:

33
After doing a code format the statment looks like:

The formatter options are

Is there any other option I can check?

BR
Dirk

Was able to reproduce with 13.2 and with last 13.1 version. It looks like we are right-handing the comments regardless of whether the checkbox that controls it is checked or not.

However, I noticed it only happens when the comment follows a statement separator (semi-colon).
We'll notify the Dev team on this.

Hello Dirk,
Nice catch - and a bug in formatter, a very old one.

I guess I'll have to explain how formatter classifies comments.

The first thing formatter does is cutting the input text into statements and loose, separating comments. We call each of these "chunks".
Then, each chunk is parsed and formatted, and comments inside are processed differently.

The said option "align at the right margin" ONLY works for the comments inside the chunk. AFAIK it works as expected.

Loose comments, found between statements and procedural blocks, should normally be aligned to the left margin. However, the one in your example, which is also a loose comment because it follows a semicolon terminated SQL statement, was moved to the right each time you formatted the code. It was moved by that many spaces as the length of the statement itself. There is/was no formatter option to control that.

I fixed the behavior in that such comments (at the RHS of a statement) will now be wrapped on a next line, and aligned to the left, just like all other loose comments. (QP-3697)
The fix will show up in one of the next betas. Watch the change log.

Thanks,
Andre