Skip to content

Commit

Permalink
start with fwdslash token, #6920
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Jul 14, 2017
1 parent d4fae70 commit c1d6786
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/vs/editor/contrib/snippet/browser/snippetParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum TokenType {
CurlyOpen,
CurlyClose,
Backslash,
Forwardslash,
Int,
VariableName,
Format,
Expand All @@ -34,6 +35,7 @@ export class Scanner {
[CharCode.OpenCurlyBrace]: TokenType.CurlyOpen,
[CharCode.CloseCurlyBrace]: TokenType.CurlyClose,
[CharCode.Backslash]: TokenType.Backslash,
[CharCode.Slash]: TokenType.Forwardslash
};

static isDigitCharacter(ch: number): boolean {
Expand Down
13 changes: 13 additions & 0 deletions src/vs/editor/contrib/snippet/test/browser/snippetParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ suite('SnippetParser', () => {
assert.equal(scanner.next().type, TokenType.Dollar);
assert.equal(scanner.next().type, TokenType.CurlyOpen);
assert.equal(scanner.next().type, TokenType.CurlyClose);

scanner.text('${foo/regex/format/option}');
assert.equal(scanner.next().type, TokenType.Dollar);
assert.equal(scanner.next().type, TokenType.CurlyOpen);
assert.equal(scanner.next().type, TokenType.VariableName);
assert.equal(scanner.next().type, TokenType.Forwardslash);
assert.equal(scanner.next().type, TokenType.VariableName);
assert.equal(scanner.next().type, TokenType.Forwardslash);
assert.equal(scanner.next().type, TokenType.VariableName);
assert.equal(scanner.next().type, TokenType.Forwardslash);
assert.equal(scanner.next().type, TokenType.VariableName);
assert.equal(scanner.next().type, TokenType.CurlyClose);
assert.equal(scanner.next().type, TokenType.EOF);
});

function assertText(value: string, expected: string) {
Expand Down

0 comments on commit c1d6786

Please sign in to comment.