Continuation indent working only on reset of initial value

Issue #1770 resolved
René Görgens created an issue

Hi Scott,

I’m declaring a method and was wondering why the continuation indent was not working although set to 4:

public static Set<Id> getAccountIdsByCategory(List<String> categoryNumbers, Boolean queryBrand,
List<String> brandNumbers) {

I toggled the continuation indent to 8 and voilà, a continuation indent of 8:

public static Set<Id> getAccountIdsByCategory(List<String> categoryNumbers, Boolean queryBrand,
        List<String> brandNumbers) {

I reset the continuation indent to 4 and now it worked:

public static Set<Id> getAccountIdsByCategory(List<String> categoryNumbers, Boolean queryBrand,
    List<String> brandNumbers) {

So it works but only after setting it to something else and then resetting it to the original value of 4.

Obviously a small bug, if it is one.

Btw I saw issue 1292 but still opened a new one, as I wasn’t sure if it’s the same.

Kind regards,

René

Comments (10)

  1. Scott Wells repo owner

    René, is this only happening to you as you're initially typing, e.g., when you type the following:

    public void doSomething(String arg1,<ENTER>)
    

    If so, it's because the parser hasn't quite determined that this is a method argument list. Once you change that to:

    public void doSomething(String arg1,
    String arg2)
    

    you can use either Auto-indent Lines or Reformat Code and it will align properly.

    I'm not saying that this is behaving in an ideal manner, but I want to make sure that we're seeing the same behavior before I start looking at a potential fix as a fix may be tricky given the incomplete parser state at the first point above.

  2. Scott Wells repo owner

    Well, it's certainly not quite acting as expected/desired. So you can confirm that it behaves as described above? If so, I can look into it a bit and see if there's something I can to do determine that it's a nascent method declaration and help it format properly even in invalid state.

  3. René Görgens reporter

    Hi Scott, yes exactly, it behaves as described above. If <ENTER> is done before the end of the signature but with nothing after <ENTER> (except the bracket), the continuation is not indented. Otherwise it is.

  4. Scott Wells repo owner

    Thanks for confirming! I'll see if I can figure out how to get it to handle this situation properly even though it's in a partially-formed parser state. I'm sure there's some recognizable context I can use for the formatting rule.

  5. Scott Wells repo owner

    Fix committed for the next build that addresses this issue in declaration formal parameter lists, invocation argument lists, trigger context lists, SOQL IN clause lists, and SOQL WITH RecordVisibilityContext config params.

  6. Log in to comment