Skip to content

Commit

Permalink
Fix handling of \ as an operator
Browse files Browse the repository at this point in the history
  • Loading branch information
Jentsch committed Oct 9, 2024
1 parent f87ee45 commit 5315ea3
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/typescript/Scala.tmLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,11 +677,11 @@ export const scalaTmLanguage: TmLanguage = {
}
},
{ // Operators with three or more characters
match: `(${opchar}${opchar}${opchar}+)`,
match: `(${opchar}|[\\\\]){3,}`,
name: 'keyword.operator.scala'
},
{ // Operators with two characters
match: `(${opchar}${opchar}|\\\\${opchar})`,
match: `((?:${opchar}|[\\\\]){2,})`,
captures: {
'1': {
patterns: [
Expand All @@ -702,7 +702,7 @@ export const scalaTmLanguage: TmLanguage = {
}
},
{ // Operators with one character
match: `(?<!${letter}_)(${opchar})`,
match: `(?<!${letter}_)(${opchar}|\\\\)`,
captures: {
'1': {
patterns: [
Expand Down
2 changes: 1 addition & 1 deletion syntaxes/Scala.tmLanguage.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions tests/snap/#191.test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a \\\ b

a \+\ b
10 changes: 10 additions & 0 deletions tests/snap/#191.test.scala.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
>a \\\ b
#^^ source.scala
# ^^^ source.scala keyword.operator.scala
# ^^^ source.scala
>
>a \+\ b
#^^ source.scala
# ^^^ source.scala keyword.operator.scala
# ^^^ source.scala
>
15 changes: 15 additions & 0 deletions tests/unit/#191.test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,18 @@
// ^^^ keyword.operator.scala
a &= b
// ^^ keyword.operator.scala

a \ b
// ^ keyword.operator.scala

a \\ b
// ^^ keyword.operator.scala

a \/ b
// ^^ keyword.operator.scala

a /\ b
// ^^ keyword.operator.scala

a \\\ b
// ^^^ keyword.operator.scala

0 comments on commit 5315ea3

Please sign in to comment.