-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infix multiplication operator screws up parentheses coloring and is highlighted in red #209
Comments
It appears to me that this is correctly captured by the grammar. See the following comparisons between Note that the color (which should be something like |
After a bunch of work to download and compile VSCode and adding the updated grammar file, the issue persists with the bracket pair colorization. There's something in the grammar that's making it unhappy with the parens. I'll keep digging! |
Found it - had to dig through VSCode's source for how it's doing its bracket colorization.
And here's what Ionide has:
Should the block comments be in there? They usually aren't in there for other languages. |
I think the block comments are in there to support automatic closing of the "brackets". CleanShot.2023-12-22.at.09.53.48.mp4You can spot an highlighting error in my video 🙈 |
That's a separate field ( |
language-configuration.json lets you define various pairs of brackets and braces for autoclosing, surrounding selected text with characters, and, as it turns out, dictating which brackets get colorized by the native bracket colorizer. As far as I can tell, putting the block comment brackets inside the `brackets` field is pointless. We color our comments green anyway, so the colors don't show anyway. It is true that F# provides support for nested comment blocks, but we aren't taking advantage of the color feature anyway (and I'm unsure if it's even possible to do so). The block comments should, however, remain in the other fields that control autocomplete and surrounding selected text.
language-configuration.json lets you define various pairs of brackets and braces for autoclosing, surrounding selected text with characters, and, as it turns out, dictating which brackets get colorized by the native bracket colorizer. As far as I can tell, putting the block comment brackets inside the `brackets` field is pointless. We color our comments green anyway, so the colors don't show anyway. It is true that F# provides support for nested comment blocks, but we aren't taking advantage of the color feature anyway (and I'm unsure if it's even possible to do so). The block comments should, however, remain in the other fields that control autocomplete and surrounding selected text.
@mbottini Thank you for the confirmation. |
language-configuration.json lets you define various pairs of brackets and braces for autoclosing, surrounding selected text with characters, and, as it turns out, dictating which brackets get colorized by the native bracket colorizer. Currently, having `(* *)` inside the `brackets` field is causing the infix multiplication operator to be treated by the bracket colorizer as two brackets: an opening `(*` and a closing `)`. Two things happen here: * The `(*` does not correspond to a corresponding `*)` bracket, so it is treated as unbalanced (hence why that part of the operator is colored red). * Absent any preceding parens in the expression, the `)` is also treated as an unbalanced paren and is colored red. This is the best case, which colors the entire operator a uniform red. Strange, but normal-looking enough that it actually looked intentional to me when I first started getting into F#. The multiplication operator is weird due to how similar it is to block comments - maybe it's supposed to be that way! * But the bug really gets exposed when there is a preceding paren in the expression such as in the expression `(Seq.fold (*) 1 [1;2;3])`. In this case, there *is* a balancing paren - the paren that precedes `Seq.fold`. Now the multiplication operator is half red (the block comment bracket never gets balanced) and half whatever the colorizer picks for the two parens. And now the closing paren after `[1;2;3]` is unbalanced and made red! As far as I can tell, putting the block comment brackets inside the `brackets` field is pointless. We color our comments green anyway, so the colors don't show anyway. It is true that F# provides support for nested comment blocks, but we aren't taking advantage of the color feature anyway (and I'm unsure if it's even possible to do so). The block comments should, however, remain in the other fields that control autocomplete and surrounding selected text.
I missed this part - that's interesting. Consider that when apart, VSCode handles them correctly: But when they're together, VSCode's bracket balancer greedily matches on |
Background: ionide/ionide-fsgrammar#209 This comes from a comment regarding a pull request that I made on the ionide-fsgrammar repository, which removes the (* *) bracket pair from the "brackets" field of language-configuration.json. One issue with doing this is that we lose the bracket-like indentation that VSCode provides by default for all bracket pairs. In other words, when I hit Enter in the following configuration, cursor location represented by the white block: (*█*) It should indent the cursor and then put the *) on the next line with the same indentation level as the (* as follows: (* █ *) when I hit Enter with an unaccompanied (*: (*█ It should simply indent as follows: (* █ Lastly, an unaccompanied `*)` should outdent. That is, *)█ should become *)█
Background: ionide/ionide-fsgrammar#209 This comes from a comment regarding a pull request that I made on the ionide-fsgrammar repository, which removes the `(* *)` bracket pair from the "brackets" field of language-configuration.json. One issue with doing this is that we lose the bracket-like indentation that VSCode provides by default for all bracket pairs. In other words, when I hit Enter in the following configuration, cursor location represented by the white block: (*█*) It should indent the cursor and then put the `*)` on the next line with the same indentation level as the `(*` as follows: (* █ *) when I hit Enter with an unaccompanied `(*`: (*█ It should simply indent as follows: (* █ Lastly, an unaccompanied `*)` should outdent. That is, *)█ should become *)█
Background: ionide/ionide-fsgrammar#209 This comes from a comment regarding a pull request that I made on the ionide-fsgrammar repository, which removes the `(* *)` bracket pair from the "brackets" field of language-configuration.json. One issue with doing this is that we lose the bracket-like indentation that VSCode provides by default for all bracket pairs. In other words, when I hit Enter in the following configuration, cursor location represented by the white block: (*█*) It should indent the cursor and then put the `*)` on the next line with the same indentation level as the `(*` as follows: (* █ *) --- When I hit Enter with an unaccompanied `(*`: (*█ It should simply indent as follows: (* █ --- Lastly, an unaccompanied `*)` should outdent. That is, *)█ should become *)█
Background: ionide/ionide-fsgrammar#209 This comes from a comment regarding a pull request that I made on the ionide-fsgrammar repository, which removes the `(* *)` bracket pair from the "brackets" field of language-configuration.json. One issue with doing this is that we lose the bracket-like indentation that VSCode provides by default for all bracket pairs. In other words, when I hit Enter in the following configuration, cursor location represented by the white block: (*█*) It should indent the cursor and then put the `*)` on the next line with the same indentation level as the `(*` as follows: (* █ *) --- When I hit Enter with an unaccompanied `(*`: (*█ It should simply indent as follows: (* █ --- Lastly, an unaccompanied `*)` should outdent. That is, *)█ should become *)█
Background: ionide/ionide-fsgrammar#209 This comes from a comment regarding a pull request that I made on the ionide-fsgrammar repository, which removes the `(* *)` bracket pair from the "brackets" field of language-configuration.json. One issue with doing this is that we lose the bracket-like indentation that VSCode provides by default for all bracket pairs. In other words, when I hit Enter in the following configuration, cursor location represented by the white block: (*█*) It should indent the cursor and then put the `*)` on the next line with the same indentation level as the `(*` as follows: (* █ *) --- When I hit Enter with an unaccompanied `(*`: (*█ It should simply indent as follows: (* █ --- Lastly, an unaccompanied `*)` should outdent. That is, *)█ should become *)█
Background: ionide/ionide-fsgrammar#209 and ionide/ionide-fsgrammar#210 This comes from a comment regarding a pull request that I made on the ionide-fsgrammar repository, which removes the `(* *)` bracket pair from the "brackets" field of language-configuration.json. One issue with doing this is that we lose the bracket-like indentation that VSCode provides by default for all bracket pairs. In other words, when I hit Enter in the following configuration, cursor location represented by the white block: (*█*) It should indent the cursor and then put the `*)` on the next line with the same indentation level as the `(*` as follows: (* █ *) --- When I hit Enter with an unaccompanied `(*`: (*█ It should simply indent as follows: (* █ --- Lastly, an unaccompanied `*)` should outdent. That is, *)█ should become *)█
Background: ionide/ionide-fsgrammar#209 and ionide/ionide-fsgrammar#210 This comes from a comment regarding a pull request that I made on the ionide-fsgrammar repository, which removes the `(* *)` bracket pair from the "brackets" field of language-configuration.json. One issue with doing this is that we lose the bracket-like indentation that VSCode provides by default for all bracket pairs. Since I'd like to remove the block comment brackets from the `language-configuration.json` file, this pull request re-adds the same semantics to the indentation rules. In other words, when I hit Enter in the following configuration, cursor location represented by the white block: (*█*) It should indent the cursor and then put the `*)` on the next line with the same indentation level as the `(*` as follows: (* █ *) --- When I hit Enter with an unaccompanied `(*`: (*█ It should simply indent as follows: (* █ --- Lastly, an unaccompanied `*)` should outdent. That is, *)█ should become *)█
Background: ionide/ionide-fsgrammar#209 and ionide/ionide-fsgrammar#210 This comes from a comment regarding a pull request that I made on the ionide-fsgrammar repository, which removes the `(* *)` bracket pair from the "brackets" field of language-configuration.json. One issue with doing this is that we lose the bracket-like indentation that VSCode provides by default for all bracket pairs. This pull request re-adds the same semantics to the indentation rules. In other words, when I hit Enter in the following configuration, cursor location represented by the white block: (*█*) It should indent the cursor and then put the `*)` on the next line with the same indentation level as the `(*` as follows: (* █ *) --- When I hit Enter with an unaccompanied `(*`: (*█ It should simply indent as follows: (* █ --- Lastly, an unaccompanied `*)` should outdent. That is, *)█ should become *)█
Oh no, I didn't realize that all of my edits to the commit message were going to get shown here! I was using the pull request window to render the Markdown! Whoops. Maybe a maintainer can collapse all of those commits... |
Describe the bug
First, the infix multiplication operator
(*)
is highlighted in red, differently from the other operators.And second, likely as a result of not being captured as a parenthesized operator, the opening paren of the operator is not counted, and the closing paren is counted for the purposes of matching corresponding parentheses. In this screenshot, the closing paren of the operator is matched with the parenthesis before
Seq.fold
:To Reproduce
Steps to reproduce the behaviour:
Open up a new file and type
(*)
to show the red-highlighted operator.Call the
(*)
operator inside of another parenthesized expression, which will cause the operator's closing paren to match with the opening paren of the outer expression.Expected behaviour
The
(*)
operator should be treated identically to the other operators. At a minimum, it should not affect the parenthesis coloring of outer expressions.Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: