eclipse-archived / ceylon.formatter

A formatter for the Ceylon programming language, written in Ceylon.
Apache License 2.0
14 stars 11 forks source link

Non-stacking indentation is discarded on comments #135

Open lucaswerkmeister opened 7 years ago

lucaswerkmeister commented 7 years ago

The formatter thinks this is the correct way to indent this code:

void f() {
    Boolean b = true ||
            true ||
            // comment
    true ||
            /*
             * comment
             */
    true ||
            true;
}

The indentation after a binary operator (two levels) never stacks, but I do think that dropping it after a comment is too eager. Making the comment token inherit the ephemeral indentation (also with never, so for inline comments it makes no difference) should solve this.

lucaswerkmeister commented 6 years ago

Works now for comments that don’t span multiple lines. Unfortunately, I don’t think I’ll be able to figure out the multi-line case until I get a working IDE setup again :/ but it’s better than nothing, at least.