Skip to content

Commit 81edefe

Browse files
committed
Fix #209: Remove (* *) from brackets config
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.
1 parent 7d029a4 commit 81edefe

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

fsharp.syntaxtest/language-configuration.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
"brackets": [
3838
["(", ")"],
39-
["(*", "*)"],
4039
["{", "}"],
4140
["[", "]"],
4241
["[|", "|]"],

sample-code/SimpleTypes.fs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ module Test =
4444
let b = ""
4545

4646
let double = (*) 2 // *) was being captured as a comment
47+
48+
// Both of these operators should have the same syntax highlighting,
49+
// specifically the infix multiplication operator.
50+
let foldSum xs = Seq.fold (+) 0 xs
51+
let foldProduct xs = Seq.fold (*) 1 xs
52+
53+
// Parenthesizing the above expression should not associate the `)`
54+
// part of the multiplication operator with the opening paren before
55+
// the expression.
56+
let foldProduct2 xs = (Seq.fold (*) 1 xs)
4757

4858
(**
4959
This block is colorized because markdown can set up his context.

0 commit comments

Comments
 (0)