Skip to content

Commit

Permalink
Update tests and remove _ around placeholders
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Aug 1, 2017
1 parent 374dcf8 commit d237486
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/emmetHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function doComplete(document: TextDocument, position: Position, syntax: s
if (expandedText) {
expandedAbbr = CompletionItem.create(abbreviation);
expandedAbbr.textEdit = TextEdit.replace(abbreviationRange, expandedText);
expandedAbbr.documentation = makeCursorsGorgeous(expandedText);
expandedAbbr.documentation = replaceTabStopsWithCursors(expandedText);
expandedAbbr.insertTextFormat = InsertTextFormat.Snippet;
expandedAbbr.detail = 'Emmet Abbreviation';
if (filters.indexOf('bem') > -1) {
Expand Down Expand Up @@ -139,7 +139,7 @@ function makeSnippetSuggestion(snippets: string[], prefix: string, abbreviation:
}

let item = CompletionItem.create(snippetKey);
item.documentation = makeCursorsGorgeous(expandedAbbr);
item.documentation = replaceTabStopsWithCursors(expandedAbbr);
item.detail = 'Emmet Abbreviation';
item.textEdit = TextEdit.replace(abbreviationRange, expandedAbbr);
item.insertTextFormat = InsertTextFormat.Snippet;
Expand Down Expand Up @@ -176,8 +176,8 @@ function getCurrentWord(document: TextDocument, position: Position): string {
}
}

function makeCursorsGorgeous(expandedWord: string): string {
return expandedWord.replace(/\$\{\d+\}/g, '|').replace(/\$\{\d+:([^\}]+)\}/g, '_$1_');
function replaceTabStopsWithCursors(expandedWord: string): string {
return expandedWord.replace(/\$\{\d+\}/g, '|').replace(/\$\{\d+:([^\}]+)\}/g, '$1');
}

function removeTabStops(expandedWord: string): string {
Expand Down
6 changes: 3 additions & 3 deletions src/emmetHelperTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ describe('Test completions', () => {
it('should provide completions', () => {
return updateExtensionsPath(null).then(() => {
const testCases: [string, number, number, string, string][] = [
['<div>ul>li*3</div>', 0, 7, 'ul', '<ul></ul>'],
['<div>ul>li*3</div>', 0, 10, 'ul>li', '<ul>\n\t<li></li>\n</ul>'],
['<div>(ul>li)*3</div>', 0, 14, '(ul>li)*3', '<ul>\n\t<li></li>\n</ul>\n<ul>\n\t<li></li>\n</ul>\n<ul>\n\t<li></li>\n</ul>']
['<div>ul>li*3</div>', 0, 7, 'ul', '<ul>|</ul>'],
['<div>ul>li*3</div>', 0, 10, 'ul>li', '<ul>\n\t<li>|</li>\n</ul>'],
['<div>(ul>li)*3</div>', 0, 14, '(ul>li)*3', '<ul>\n\t<li>|</li>\n</ul>\n<ul>\n\t<li>|</li>\n</ul>\n<ul>\n\t<li>|</li>\n</ul>']
];

testCases.forEach(([content, positionLine, positionChar, expectedAbbr, expectedExpansion]) => {
Expand Down

0 comments on commit d237486

Please sign in to comment.