Multi-line indentation a.k.a. rough code formatting [v0.4.9]

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

  • timothee.cour
    January 21, 2013 - 10:47 pm | Permalink

    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.

    • timothee.cour
      January 21, 2013 - 10:48 pm | Permalink

      the comment autoformatter removed the space before the first import.stdio above. But you get the idea.

      • alex
        January 21, 2013 - 10:55 pm | Permalink

        The first line..yeah.. why isn’t it doing that :D

        • timothee.cour
          January 21, 2013 - 11:04 pm | Permalink

          another bug:

          /+
          a
          +/

          yields:

          /+
          a
          +/
          (in case comment formatter screws up: it adds a space on 2nd and 3rd line)

          • alex
            January 21, 2013 - 11:06 pm | Permalink

            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..

            • timothee.cour
              January 21, 2013 - 11:16 pm | Permalink

              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.

            • alex
              January 21, 2013 - 11:21 pm | Permalink

              Completion just works for me(tm) – I could cry sometimes because I don’t know why people are complaining about non-working features D:
              :D

  • Leave a Reply

    Your email address will not be published. Required fields are marked *


    nine × = 45

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>