tlaplus / vscode-tlaplus

TLA+ language support for Visual Studio Code
MIT License
340 stars 29 forks source link

Unexpected auto-indentation for PlusCal c-syntax #120

Closed dricketts closed 4 years ago

dricketts commented 4 years ago

Indentation sometimes is a bit surprising for PlusCal c-syntax. If an algorithm has a procedure, then the plugin properly indents within the procedure, but also seems to continue to indent after the closing bracket of the procedure. For example, in the following algorithm, going to a new line after the closing bracket of F moves the cursor to the next indentation level.

(*--algorithm Test
{
    procedure F() {
        l2: skip;
    }

    process (P \in {})
    {
        l1: skip;
    }

}
*)

Glancing at src/formatters/tla.ts, it looks like the block begin and end logic does not look for { and }, but rather begin and end of the p-syntax.

alygin commented 4 years ago

You're right, the PlusCal indentation doesn't work as expected with the c-syntax. I need to fix that.

alygin commented 4 years ago

@dricketts, it's fixed and will be delivered as a part of the v1.3.0 release.

BTW, if you put the algorithm closing curly brace and the closing comment parenthesis on the same line (} *)), you'll get better TLA+ highlighting. The same problem as in #104.

dricketts commented 4 years ago

Awesome, thanks.

I forgot about putting the closing comment on the same line as the closing curly brace. Thanks for reminding me.

alygin commented 4 years ago

@dricketts, the auto-indentation should work better with C-syntax in just released v1.3, so I'm closing the issue. Please, feel free to reopen it should the problem remain.