vscode-tlaplus icon indicating copy to clipboard operation
vscode-tlaplus copied to clipboard

PlusCal syntax highlighting breaks if --algorithm is not on line of open comment

Open dricketts opened this issue 6 years ago • 6 comments

This is extremely minor, but maybe worth noting in a wiki page. PlusCal syntax highlighting won't work if the algorithm is written as:

(*
--algorithm WriteStealing
{
{
    skip;
}
}
*)

However, it does work if the algorithm is written as:

(*--algorithm WriteStealing
{
{
    skip;
}
}
*)

dricketts avatar Sep 26 '19 00:09 dricketts

You're right, in a couple of cases the extension doesn't capture boundaries of a PlusCal algorithm correctly. There's a quick fix for this particular issue, but unfortunately, it brings other highlighting problems. VS Code has some limitations on grammar parsing, especially when it comes to embedded languages (PlusCal inside TLA+).

So, for the time being, I'll leave the highlighting rules as they are. But I'll add some kind of Caveats section to the Wiki. Thanks for the idea!

alygin avatar Sep 26 '19 18:09 alygin

Here it is: Caveats

alygin avatar Oct 02 '19 17:10 alygin

Thanks, that looks good to me.

dricketts avatar Oct 06 '19 23:10 dricketts

There's an attempt to improve VS Code highlighting capabilities: https://github.com/microsoft/vscode/issues/77133. I hope the result will allow us to fix this issue.

alygin avatar Oct 07 '19 09:10 alygin

BTW, it's also better to keep the closing curly bracket on the last comment line:

(*--algorithm WriteStealing {
{
    skip;
}
} *)

The extension starting with version 1.2 handles it better.

alygin avatar Oct 20 '19 11:10 alygin

A similar problem if opening bracket of define is on the next line:

define
{
   ...
}

See https://github.com/lemmy/azure-cosmos-tla/blob/6e4e505a663ced50a61120219a70c7a2c1ae0f17/general-model/cosmos_client.tla#L84-L85

lemmy avatar Feb 26 '22 01:02 lemmy