Typing a method annotiation (i.e. @isTest) and pressing return starts the next line indented

Issue #247 resolved
Chris Peterson created an issue

If you try and type something like:

@isTest
static void blah(){}

You'll instead get

@isTest
        static void blah(){}

It appears that starting with the annotiation first on it's own line causes IC to see the next line as a continuation and apply the (by default) 8-space continuation indent. Since it's a method level annotation this isn't right - the method should be at the same indent level as the annotations on it according to all code styles I've seen to date.

Comments (6)

  1. Scott Wells repo owner

    Funny...here's a TODO I left for myself in the formatter:

    // TODO: Multiple annotations aren't formatting quite right; the second annotation ends up on a continuation indent
    
  2. Matt Simonis

    I'd love to see this fixed. Minor annoyance when I write unit tests (which is almost every day). Small workaround I've done is put a test method below the ones I want to write, and then it will format fine. See below.

    @isTest
    private class TestClass {
        // Write tests here with @isTest annotation and they will format without issue because of the test below.
    
        @isTest
        private static void notARealTest() {}
    }
    
  3. Scott Wells repo owner

    Okay, this will be fixed in the next build, not just for @IsTest for but all annotations typed as the leading part of a new declaration.

  4. Log in to comment