-
-
Notifications
You must be signed in to change notification settings - Fork 3
Description
This seems like the biggest bug currently.
If we could get correct indentation at and around statements continued across linebreaks, I could probably code for a while without needing to use dartfmt as often.
Here's an example, taken from the dart style guide, formatted incorrectly by dart-mode.
var bobLikesIt = isDeepFried || //
(hasPieCrust && !vegan) || //
containsBacon;
bobLikes() => //
isDeepFried || (hasPieCrust && !vegan) || containsBacon;In other words, if you've formatted correctly at line three, then dart-mode indents incorrectly at line five, and the user is looking forward to typing out a parsable file again so that line five will be fixed.
I think this is more important than getting the amount of indentation perfect, for example, matching dartfmt exactly, or knowing when to indent by two or four spaces. The indentation above not only differs from dartfmt, but is a bit harder to read.
To illustrate what I mean by the difference between two and four not being as important, I think the following would be satisfactory if dart-mode could get it correctly:
var bobLikesIt = isDeepFried || //
(hasPieCrust && !vegan) || //
containsBacon;
bobLikes() => //
isDeepFried || (hasPieCrust && !vegan) || containsBacon;I think readable code is a reasonable target for dart-mode indentation function, and not as important as matching dartfmt perfectly. The user can wait for dartfmt to be applied at a convenient time. After all, dart-mode's indentation can come in handy when the file is not parsable.
The best approach would seem to be to read and understand the indentation function from go-mode.el, as it looks to be very concise and solve a similar problem.