editorconfig / editorconfig-jetbrains

A JetBrains IDE plugin supporting the EditorConfig standard
MIT License
291 stars 21 forks source link

Continuation indent size is overridden by regular indent size #57

Open rkrisztian opened 8 years ago

rkrisztian commented 8 years ago

Hi,

IDEA supports the concept of continuation indent. Its size is usually configured to twice as much as the regular indent size. Continuation indent can occur if e.g. you wrap the first line of an "if" or "for" or "try" statement in Java (and others like variable assignments, etc.). Continuation indent can also increase readability. Consider a line wrapped just before a block start in the case you use K&R style braces, and you don't wrap the lines around the parentheses. Then without a different indentation, it is hard to see whether the next line belongs to the block, or still to first line of the statement. And the EditorConfig plugin forces us to use the same indentation setting for continuation indentation as for regular indentation.

Example Java code without the EditorConfig support:

        try (FileInputStream x = new FileInputStream(new File("x"));
                FileInputStream x2 = new FileInputStream(new File("x2"));
                FileInputStream x3 = new FileInputStream(new File("x3"))) {
            System.out.println("x");
        }

Example Java code with the EditorConfig support enabled:

        try (FileInputStream x = new FileInputStream(new File("x"));
            FileInputStream x2 = new FileInputStream(new File("x2"));
            FileInputStream x3 = new FileInputStream(new File("x3"))) {
            System.out.println("x");
        }

I believe this is a bug of the plugin, and a decent fix may need a co-operation between the EditorConfig developers to add support for continuation indent (it is somewhat language specific though).

KurtYoung commented 8 years ago

+1 same here, took me 1 hour to figure out.

WoodenDoors commented 7 years ago

+1 And here I thought I was going mad, when I found nothing that explained this in the IDEA Bug Tracker. I'll probably just remove indent_size everywhere for now, since this breaks a lot of java code style.

seanf commented 7 years ago

I found that the IDEA-specific setting continuation_indent_size = 8 helped.

See also https://youtrack.jetbrains.com/issue/IDEA-145069

retrodaredevil commented 4 years ago

I think that this issue is mostly fixed, however when using indent_style = tab, there is no way to set continuation_indent_size without defining how wide a tab character is. One of the benefits of using the tab character is that anyone can choose what they want the width of the tab character to be.

It would be nice if we could have something like this: continuation_indent_size = tab_width * 2, or something along that line.