Closed Hixie closed 2 years ago
Okay, I think I may have found a solution that fits your description.1
Apparently both closing parens and pressing return for a new line, causes "reindentation" of the "already indented" line. And this might be fixed with setting electric-indent-inhibit
to t
in dart-mode.
I will try this in my local config, to see if it improves the situations.
(with-eval-after-load "dart-mode"
(add-to-list 'dart-mode-hook (lambda () (setq electric-indent-inhibit t)))
If we find it works with an overall better user experience, I presume we can add this as a local default in the dart-mode.el source code.
Thank you for formulating, raising and expounding on this particular question, I suspect this partial issue and fix will make editing Dart code in Emacs a bit more pleasant.
Note that dart-mode's indentation function still does not get the "deindent" right after ending a continued statement with a semicolon. I noticed the indentation function of go-mode.el has seen some changes, I hope the next time I attempt to mimic their approach, I will have an easier time, and we can see better emacs indentation in dart-mode. Mostly I've been just tolerating this general issue.
1: indentation - Change the behaviour of RET (with electric indent) to only indent the new line, not the previous one - Emacs Stack Exchange.html
Oh that's perfect, that's exactly what I want I think. Thanks so much!
I've added the setting to main
branch at https://github.com/bradyt/dart-mode/commit/ae032b9b30ebadfe1b8a48a4cf278417e506d100. Closing optimistically. Feedback welcome.
(I've read https://github.com/bradyt/dart-mode/wiki/Indentation-and-Syntax-Highlighting)
I like how when I hit enter, the cursor appears on the next line at a somewhat-reasonable place. However, I don't like that when I hit enter (or type a bracket or some other punctuation) the line the cursor was on gets reindented.
For example, suppose I type this:
When I press the
)
character, it undoes my manually-performed indentation:So I fix it by going back to the start of the line:
...then I fill in the first argument:
...and as soon as I press the
)
key:...so I go and fix it again:
...and enter the second argument,
, () { }
... and it "fixes" my indentation again at the)
and the}
.Is there any way to set things up so that existing indentation is never changed?