Skip to content

Commit

Permalink
[JavaScript] More regexp literal fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wbond committed Feb 24, 2016
1 parent 06ffdbb commit d3baaed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions JavaScript/JavaScript.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,14 @@ contexts:
literal-regexp:
# Lookahead and prevent incorrect matches by finding a / following an
# identifier or number. Not perfect, but stops most incorrect matches
- match: '(?=({{identifier}}|0[xob]\d+|\d+|\d*\.\d*(e[-+]?\d+)?)\s*/[^/])'
- match: '(?=({{identifier}}|0[xob]\d+|\d+|\d*\.\d*(e[-+]?\d+)?)\s*/[^/*])'
push:
- include: comments
- match: '/'
scope: keyword.operator.arithmetic.js
pop: true
- include: expressions-no-regexp
- match: '/(?=.+/[gimy]*(?!\s*[a-zA-Z0-9_$]))'
- match: '/(?=(?:[^/\\]|\\.)+/(?![/*])[gimy]*(?!\s*[a-zA-Z0-9_$]))'
scope: punctuation.definition.string.begin.js
push:
- meta_scope: string.regexp.js
Expand Down
10 changes: 10 additions & 0 deletions JavaScript/syntax_test_js.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,3 +499,13 @@ var result = 200 / 400 + 500 /
// ^ keyword.operator.arithmetic
// ^ keyword.operator.arithmetic
100;

var angle = 2*π / count // angle between circles
// ^ keyword.operator.arithmetic

var angle = 2*π / count /* angle between circles */
// ^ keyword.operator.arithmetic

a = /foo\/bar/g // Ensure handling of escape / in regex detection
// ^ string.regexp
// ^ constant.character.escape

0 comments on commit d3baaed

Please sign in to comment.