Delimiter-separated lists of symbols laid out vertically get extra indents

Issue #1135 resolved
Alan Birchenough created an issue

Two things to start with:

  • This issue isn't super urgent or big, but it does waste some of my time;
  • It may be a problem with IC, or perhaps with IntelliJ's Java support, if you happen to be reusing that behavior somehow. (I think I have seen a similar issue when editing Java in IC.)

As you know, it is bad practice to let lines get too long, which in my book means beyond character position 120. Apex language constructs that frequently threaten to overrun this limit are select lists in SOQL queries and field initializations in SObject constructors.

When I lay these out "vertically" I would hope that the editor would let me indent like this:

2018-10-12_1239.png

whereas it insists on giving me this:

2018-10-12_1240.png.

A select list example looks like this:

2018-10-12_1242.png.

Here a SEL* on ffbc__SoftDate__c has given me two unnecessary indentation levels. The SELECT and FROM keywords start one indent too far to the right, and the selected field list is one indent further to the right relative to the SELECT / FROM column than necessary or desirable.

In practice, I spend quite a bit of time fighting for the indentation I want by manually outdenting lines that have been automatically indented too much.

Do you have recommendations on how to work more efficiently with the indents that the editor gives me in these scenarios? Is there some setting I have missed, or is this actually a minor bug? I would be interested in your analysis.

Comments (5)

  1. Scott Wells repo owner

    Alan, you need to set your continuation indent to the same as your standard indent:

    Issue1135.png

    Reformat after making that change and let me know if it doesn't format as you'd like.

  2. Alan Birchenough reporter

    Yep. That fixed it. That leaves me with two follow-on thoughts: (1) Why would anyone ever want the continuation indent to be 8 (rhetorical); (2) when and how will I ever get to grips with the profusion of settings in IJ?

    At any rate, thanks for pointing this one out.

  3. Scott Wells repo owner

    Yeah, I've had the same question (your first one), though I have seen some that prefer, say, a 2 space normal indent and a 4 space continuation indent. It looks strange to me, personally, but that's why you give folks all of these config options. For what it's worth, that's a characteristic of the standard formatter, not something unique to IC. Regarding your second question, obviously one of the key benefits of building a plugin for such a powerful and full-featured IDE as IntelliJ IDEA/WebStorm is that you get so much for "free". However, it does mean that you also inherit the inherent complexities that support that power and those features. Except where behavior is 100% Salesforce-specific, e.g., deployment/retrieval/SFDX behavior, I've tried to extend the base IDE's functionality for Salesforce dev. As a result, the standard JetBrains config documentation is a very valuable resource:

    https://www.jetbrains.com/help/idea/configuring-project-and-ide-settings.html

    That's probably the best way to familiarize yourself with how things work. It can be a steep learning curve--I've been using these IDEs for 15 years plus or minus a few and I still find things I didn't even know were there. And don't ever hesitate to send questions my way either. I'm always happy to help.

  4. Log in to comment