Skip to content

Commit

Permalink
Fixes microsoft#3552: Parse \$ as $ in TM snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Mar 17, 2016
1 parent 8bc67cb commit 42f6a50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/vs/editor/contrib/snippet/common/snippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,11 @@ export class CodeSnippet implements ICodeSnippet {
// Escapes
if (/^\\./.test(restOfLine)) {
i += 2;
convertedSnippet += restOfLine.substr(0, 2);
if (/^\\\$/.test(restOfLine)) {
convertedSnippet += '$';
} else {
convertedSnippet += restOfLine.substr(0, 2);
}
continue;
}

Expand Down
8 changes: 8 additions & 0 deletions src/vs/editor/contrib/snippet/test/common/snippet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,13 @@ suite('Editor Contrib - Snippets', () => {
assert.equal(snippet.placeHolders[1].occurences.length, 1);
assert.deepEqual(snippet.placeHolders[1].occurences[0], new Range(2, 2, 2, 2));
});

test('issue #3552: Snippet Converted Not Working for literal Dollar Sign', () => {

let external = '\n\\$scope.\\$broadcast(\'scroll.infiniteScrollComplete\');\n';
let internal = CodeSnippet.convertExternalSnippet(external, ExternalSnippetType.TextMateSnippet);

assert.equal(internal, '\n$scope.$broadcast(\'scroll.infiniteScrollComplete\');\n');
});
});

0 comments on commit 42f6a50

Please sign in to comment.