提交 5769bebb 编写于 作者: R Ramya Achutha Rao

Enable the use of comment filter in emmet

上级 4d7a7a15
......@@ -38,9 +38,9 @@
"resolved": "https://registry.npmjs.org/image-size/-/image-size-0.5.5.tgz"
},
"vscode-emmet-helper": {
"version": "1.1.0",
"from": "vscode-emmet-helper@>=1.1.0 <2.0.0",
"resolved": "https://registry.npmjs.org/vscode-emmet-helper/-/vscode-emmet-helper-1.1.0.tgz"
"version": "1.1.1",
"from": "vscode-emmet-helper@>=1.1.1 <2.0.0",
"resolved": "https://registry.npmjs.org/vscode-emmet-helper/-/vscode-emmet-helper-1.1.1.tgz"
},
"vscode-languageserver-types": {
"version": "3.3.0",
......
......@@ -259,7 +259,7 @@
"@emmetio/html-matcher": "^0.3.1",
"@emmetio/css-parser": "ramya-rao-a/css-parser#vscode",
"@emmetio/math-expression": "^0.1.1",
"vscode-emmet-helper": "^1.1.0",
"vscode-emmet-helper": "^1.1.1",
"vscode-languageserver-types": "^3.0.3",
"image-size": "^0.5.2",
"vscode-nls": "2.0.2"
......
......@@ -15,7 +15,7 @@ interface ExpandAbbreviationInput {
abbreviation: string;
rangeToReplace: vscode.Range;
textToWrap?: string[];
filters?: string[];
filter?: string;
}
export function wrapWithAbbreviation(args) {
......@@ -73,13 +73,13 @@ export function wrapIndividualLinesWithAbbreviation(args) {
return;
}
let { abbreviation, filters } = extractedResults;
let { abbreviation, filter } = extractedResults;
let input: ExpandAbbreviationInput = {
syntax,
abbreviation,
rangeToReplace: editor.selection,
textToWrap: lines,
filters
filter
};
return expandAbbreviationInRange(editor, [input], true);
......@@ -106,15 +106,15 @@ export function expandEmmetAbbreviation(args): Thenable<boolean> {
let firstAbbreviation: string;
let allAbbreviationsSame: boolean = true;
let getAbbreviation = (document: vscode.TextDocument, selection: vscode.Selection, position: vscode.Position, syntax: string): [vscode.Range, string, string[]] => {
let getAbbreviation = (document: vscode.TextDocument, selection: vscode.Selection, position: vscode.Position, syntax: string): [vscode.Range, string, string] => {
let rangeToReplace: vscode.Range = selection;
let abbr = document.getText(rangeToReplace);
if (!rangeToReplace.isEmpty) {
let extractedResults = extractAbbreviationFromText(abbr);
if (extractedResults) {
return [rangeToReplace, extractedResults.abbreviation, extractedResults.filters];
return [rangeToReplace, extractedResults.abbreviation, extractedResults.filter];
}
return [null, '', []];
return [null, '', ''];
}
const currentLine = editor.document.lineAt(position.line).text;
......@@ -127,21 +127,21 @@ export function expandEmmetAbbreviation(args): Thenable<boolean> {
if (matches) {
abbr = matches[1];
rangeToReplace = new vscode.Range(position.translate(0, -(abbr.length + 1)), position);
return [rangeToReplace, abbr, []];
return [rangeToReplace, abbr, ''];
}
}
let extractedResults = extractAbbreviation(editor.document, position, false);
if (!extractedResults) {
return [null, '', []];
return [null, '', ''];
}
let { abbreviationRange, abbreviation, filters } = extractedResults;
return [new vscode.Range(abbreviationRange.start.line, abbreviationRange.start.character, abbreviationRange.end.line, abbreviationRange.end.character), abbreviation, filters];
let { abbreviationRange, abbreviation, filter } = extractedResults;
return [new vscode.Range(abbreviationRange.start.line, abbreviationRange.start.character, abbreviationRange.end.line, abbreviationRange.end.character), abbreviation, filter];
};
editor.selections.forEach(selection => {
let position = selection.isReversed ? selection.anchor : selection.active;
let [rangeToReplace, abbreviation, filters] = getAbbreviation(editor.document, selection, position, syntax);
let [rangeToReplace, abbreviation, filter] = getAbbreviation(editor.document, selection, position, syntax);
if (!rangeToReplace) {
return;
}
......@@ -160,7 +160,7 @@ export function expandEmmetAbbreviation(args): Thenable<boolean> {
allAbbreviationsSame = false;
}
abbreviationList.push({ syntax, abbreviation, rangeToReplace, filters });
abbreviationList.push({ syntax, abbreviation, rangeToReplace, filter });
});
return expandAbbreviationInRange(editor, abbreviationList, allAbbreviationsSame).then(success => {
......@@ -272,11 +272,11 @@ function expandAbbreviationInRange(editor: vscode.TextEditor, expandAbbrList: Ex
*/
function expandAbbr(input: ExpandAbbreviationInput): string {
const emmetConfig = vscode.workspace.getConfiguration('emmet');
const expandOptions = getExpandOptions(input.syntax, emmetConfig, input.filters);
const expandOptions = getExpandOptions(input.syntax, emmetConfig, input.filter);
if (input.textToWrap) {
if (input.filters && input.filters.indexOf('t') > -1) {
if (input.filter && input.filter.indexOf('t') > -1) {
input.textToWrap = input.textToWrap.map(line => {
return line.replace(trimRegex, '').trim();
});
......
......@@ -40,12 +40,6 @@ const scssContents = `
}
`
const bemFilterExample = 'ul.search-form._wide>li.-querystring+li.-btn_large|bem';
const expectedBemFilterOutput = `<ul class="search-form search-form_wide">
<li class="search-form__querystring"></li>
<li class="search-form__btn search-form__btn_large"></li>
</ul>`;
const htmlContents = `
<body class="header">
<ul class="nav main">
......@@ -62,7 +56,7 @@ const htmlContents = `
m10
}
</style>
${bemFilterExample}
<span></span>
(ul>li.item$)*2
(ul>li.item$)*2+span
(div>dl>(dt+dd)*2)
......@@ -188,11 +182,6 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
});
});
// TODO@Ramya test failing on our build machines on macOS
// test('Expand using bem filter', () => {
// return testHtmlExpandAbbreviation(new Selection(16, 55, 16, 55), bemFilterExample, expectedBemFilterOutput);
// });
});
suite('Tests for Expand Abbreviations (CSS)', () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册