Formatter engine frustration

I want to start a topic about code formatting. I file a lot of bugs and
feature requests for IDEA but I haven't filed many for formatting issues
in a few years, since pre 4.0, when I gave up trying to provide feedback
to improve it. I felt that it was a lost cause. But, now I want to talk
about it because I think it's getting silly, that IDEA has had a
formatting engine for years now, and it's still in such a bad state.

Ever since the 4.0 EAP, the formatter almost never runs when I want it
to, and it almost never formats the way I want my code to look. It seems
to randomly wrap lines. Sometimes IDEA will create a method with some
intenttion or refactoring, and it will wrap the parameter list but still
go way past the right margin. Other times it will do things I obviously
didn't want, nor would 99% of people want, like create a constructor
"public SomeClass() {code();}", or create new lines at awkward parts of
a long line which makes the code hard to read. Still other times, it
will wrap lines for no apparent reason to something like 60 or 40
columns (my setting is 80). So you'll see a line produced by the
formatter like:
someMethod(someVariable,
someOtherVariable, someOtherVariable2);

Additionally, it has the setting "keep line breaks." Well maybe this
sounds cool, but when I use the formatter, I want IDEA to remove line
breaks in a lot of places (array initializers, enums, method parameters,
for example), but never touch line breaks in other places (I leave blank
lines in certain places in code, like before an else). So, I want to be
able to selectively tell IDEA how serious I want it to be about line breaks.

I wonder if anyone else feels this way about the formatter. Maybe if
enough of us have problems we can all vote for some issues we decide to
report about it.

1 comment
Comment actions Permalink

I am not particularly happy about the formatter myself, in particular
the way it handles line wrapping. It seems to regard the right margin as
a mere suggestion and not as a hard limit.

I am surprised that JetBrains is not able to find these bugs for
themselves since they manifest so obviously when you write/edit code.

Ciao,
Gordon

--
Gordon Tyler (Software Developer)
Quest Software <http://www.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: (416) 933-5046 | Fax: (416) 933-5001

0

Please sign in to leave a comment.