Skip to content

Commit

Permalink
Fix #37
Browse files Browse the repository at this point in the history
  • Loading branch information
rzhao271 committed Dec 30, 2020
1 parent 4a97cc0 commit 4d59a1e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/emmetHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ export function getExpandOptions(syntax: string, emmetConfig?: VSCodeEmmetConfig
'output.compactBoolean': profile['compactBooleanAttributes'] ?? preferences['profile.allowCompactBoolean'],
// 'output.booleanAttributes': string[],
// 'output.reverseAttributes': boolean,
'output.selfClosingStyle': profile['selfClosingStyle'],
'output.selfClosingStyle': profile['selfClosingStyle'] ?? getClosingStyle(syntax),
'output.field': emmetSnippetField,
// 'output.text': TextOutput,
// 'markup.href': boolean,
Expand Down Expand Up @@ -683,6 +683,15 @@ export function getExpandOptions(syntax: string, emmetConfig?: VSCodeEmmetConfig
};
}

function getClosingStyle(syntax: string): string {
switch (syntax) {
case 'xhtml': return 'xhtml';
case 'xml': return 'xml';
case 'xsl': return 'xml';
default: return 'html';
}
}

function splitVendorPrefix(abbreviation: string): { prefixOptions: string, abbreviationWithoutPrefix: string } {
if (!vendorPrefixesEnabled) {
return {
Expand Down
3 changes: 3 additions & 0 deletions src/test/expand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ describe('Expand Abbreviations', () => {
testExpandWithCompletion('css', 'opa1', 'opacity: 1;');
testExpandWithCompletion('css', 'opa.a', 'opacity: .a;');

// https://github.com/microsoft/vscode-emmet-helper/issues/37
testExpandWithCompletion('xsl', 'cp/', '<xsl:copy select="${0}"/>')

// escaped dollar signs should not change after going through Emmet expansion only
// VS Code automatically removes the backslashes after the expansion
testExpand('html', 'span{\\$5}', '<span>\\$5</span>');
Expand Down

0 comments on commit 4d59a1e

Please sign in to comment.