Hi everyone,
I recognized that building the entire ast visitor dedicated for D code formatting takes a bit more.
Despite this I found a (temporary) shortcut that represents a fairly good compromise regarding ‘early release date’ vs. ‘good formatting results’:
To let the indent engine indent each line individually without re-arranging brackets or other tokens.
You’ll be able now to call the formatter via Edit -> Format -> Format Document (also Format Selection if you’ve selected a couple of lines only).
You can of course switch to the actual (intrusive) formatting engine by un-checking the lower-most check box in the D Options – but be aware that it still tends to throw undefined exceptions whose error messages won’t really make sense – so please don’t flood the issue tracker with not very helpful stack trace dumps
7 Comments
great! Thanks for tackling this at last!
Not sure why ppl replied they don’t use that feature.
here’s one bug:
the 1st line doesn’t seem to get formatted. eg:
—-
import std.stdio;
—-
pressing control + I should yield:
—-
import std.stdio;
—-
but it doesn’t.
the comment autoformatter removed the space before the first import.stdio above. But you get the idea.
The first line..yeah.. why isn’t it doing that
another bug:
/+
a
+/
yields:
/+
a
+/
(in case comment formatter screws up: it adds a space on 2nd and 3rd line)
That’s definitely not a bug – it’s intended to have multi-line comments start at the same columns. I guess I have to make it opt-in/out or so then..
okay, optin/out avoids flaming wars about what’s the right thing to do…
unrelated:
it doesn’t seem to do completion anymore?
eg i set the paths to phobos and druntime, but if i start writing import std.stdio, it doesn’t auto-complete. Not sure when was the last release that worked.
Completion just works for me(tm) – I could cry sometimes because I don’t know why people are complaining about non-working features D: