Skip to content

Commit

Permalink
Merge pull request #148 from msftrncs/ScopeSubst#147
Browse files Browse the repository at this point in the history
Make scope capture substitution regex global
  • Loading branch information
alexdima committed Mar 23, 2021
2 parents 6e5409d + 30759cc commit 4fefcf3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ export function basename(path: string): string {
}
}

let CAPTURING_REGEX_SOURCE = /\$(\d+)|\${(\d+):\/(downcase|upcase)}/;
let CAPTURING_REGEX_SOURCE = /\$(\d+)|\${(\d+):\/(downcase|upcase)}/g;

export class RegexSource {

public static hasCaptures(regexSource: string | null): boolean {
if (regexSource === null) {
return false;
}
CAPTURING_REGEX_SOURCE.lastIndex = 0;
return CAPTURING_REGEX_SOURCE.test(regexSource);
}

Expand Down
9 changes: 9 additions & 0 deletions test-cases/suite1/fixtures/147.grammar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"scopeName": "source.test",
"patterns": [
{
"match": "\\b(?i:function)\\b",
"name": "storage.type.$0 keyword.declaration.$0"
}
]
}
22 changes: 22 additions & 0 deletions test-cases/suite1/tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -1806,5 +1806,27 @@
]
}
]
},
{
"grammars": [
"fixtures/147.grammar.json"
],
"grammarPath": "fixtures/147.grammar.json",
"desc": "Issue #147",
"lines": [
{
"line": "Function",
"tokens": [
{
"value": "Function",
"scopes": [
"source.test",
"storage.type.Function",
"keyword.declaration.Function"
]
}
]
}
]
}
]

0 comments on commit 4fefcf3

Please sign in to comment.