Archived
1
0

chore(vscode): update to 1.56.0

This commit is contained in:
Akash Satheesan
2021-04-30 20:25:17 +05:30
1749 changed files with 88014 additions and 43316 deletions

View File

@ -205,7 +205,7 @@ export async function wrapWithAbbreviation(args: any): Promise<boolean> {
let inPreviewMode = false;
async function makeChanges(inputAbbreviation: string | undefined, previewChanges: boolean): Promise<boolean> {
const isAbbreviationValid = !!inputAbbreviation && !!inputAbbreviation.trim() && helper.isAbbreviationValid(syntax, inputAbbreviation);
const extractedResults = isAbbreviationValid ? helper.extractAbbreviationFromText(inputAbbreviation!) : undefined;
const extractedResults = isAbbreviationValid ? helper.extractAbbreviationFromText(inputAbbreviation!, syntax) : undefined;
if (!extractedResults) {
if (inPreviewMode) {
inPreviewMode = false;
@ -311,12 +311,12 @@ export function expandEmmetAbbreviation(args: any): Thenable<boolean | undefined
let allAbbreviationsSame: boolean = true;
const helper = getEmmetHelper();
const getAbbreviation = (document: vscode.TextDocument, selection: vscode.Selection, position: vscode.Position, syntax: string): [vscode.Range | null, string, string] => {
const getAbbreviation = (document: vscode.TextDocument, selection: vscode.Selection, position: vscode.Position, syntax: string): [vscode.Range | null, string, string | undefined] => {
position = document.validatePosition(position);
let rangeToReplace: vscode.Range = selection;
let abbr = document.getText(rangeToReplace);
if (!rangeToReplace.isEmpty) {
const extractedResults = helper.extractAbbreviationFromText(abbr);
const extractedResults = helper.extractAbbreviationFromText(abbr, syntax);
if (extractedResults) {
return [rangeToReplace, extractedResults.abbreviation, extractedResults.filter];
}

View File

@ -176,7 +176,8 @@ export class DefaultCompletionItemProvider implements vscode.CompletionItemProvi
return;
}
let result = helper.doComplete(toLSTextDocument(document), position, syntax, getEmmetConfiguration(syntax!));
const config = getEmmetConfiguration(syntax!);
const result = helper.doComplete(toLSTextDocument(document), position, syntax, config);
// https://github.com/microsoft/vscode/issues/86941
if (result && result.items && result.items.length === 1) {

View File

@ -19,7 +19,7 @@ import { evaluateMathExpression } from './evaluateMathExpression';
import { incrementDecrement } from './incrementDecrement';
import { LANGUAGE_MODES, getMappingForIncludedLanguages, updateEmmetExtensionsPath, migrateEmmetExtensionsPath, getPathBaseName, getSyntaxes, getEmmetMode } from './util';
import { reflectCssValue } from './reflectCssValue';
import { addFileToParseCache, removeFileFromParseCache } from './parseDocument';
import { addFileToParseCache, clearParseCache, removeFileFromParseCache } from './parseDocument';
export function activateEmmetExtension(context: vscode.ExtensionContext) {
migrateEmmetExtensionsPath();
@ -203,4 +203,6 @@ function registerCompletionProviders(context: vscode.ExtensionContext) {
}
export function deactivate() {
completionProvidersMapping.clear();
clearParseCache();
}

View File

@ -44,3 +44,7 @@ export function removeFileFromParseCache(document: TextDocument) {
const filename = document.uri.toString();
_parseCache.delete(filename);
}
export function clearParseCache() {
_parseCache.clear();
}

View File

@ -19,7 +19,7 @@ export function nextItemHTML(document: vscode.TextDocument, selectionStart: vsco
if (currentNode.type !== 'comment') {
// If cursor is in the tag name, select tag
if (currentNode.open &&
selectionEndOffset < currentNode.open.start + currentNode.name.length) {
selectionEndOffset <= currentNode.open.start + currentNode.name.length) {
return getSelectionFromNode(document, currentNode);
}

View File

@ -44,10 +44,7 @@ const htmlContents = `
suite('Tests for Expand Abbreviations (HTML)', () => {
const oldValueForExcludeLanguages = workspace.getConfiguration('emmet').inspect('excludeLanguages');
const oldValueForInlcudeLanguages = workspace.getConfiguration('emmet').inspect('includeLanguages');
teardown(() => {
// close all editors
return closeAllEditors;
});
teardown(closeAllEditors);
test('Expand snippets (HTML)', () => {
return testExpandAbbreviation('html', new Selection(3, 23, 3, 23), 'img', '<img src=\"\" alt=\"\">');
@ -442,7 +439,7 @@ suite('Tests for jsx, xml and xsl', () => {
return withRandomFileEditor('img', 'javascriptreact', async (editor, _doc) => {
editor.selection = new Selection(0, 6, 0, 6);
await expandEmmetAbbreviation({ language: 'javascriptreact' });
assert.strictEqual(editor.document.getText(), '<img src="" alt=""/>');
assert.strictEqual(editor.document.getText(), '<img src="" alt="" />');
return Promise.resolve();
});
});
@ -452,7 +449,7 @@ suite('Tests for jsx, xml and xsl', () => {
return withRandomFileEditor('img', 'javascriptreact', async (editor, _doc) => {
editor.selection = new Selection(0, 6, 0, 6);
await expandEmmetAbbreviation({ language: 'javascriptreact' });
assert.strictEqual(editor.document.getText(), '<img src=\'\' alt=\'\'/>');
assert.strictEqual(editor.document.getText(), '<img src=\'\' alt=\'\' />');
return workspace.getConfiguration('emmet').update('syntaxProfiles', oldValueForSyntaxProfiles ? oldValueForSyntaxProfiles.globalValue : undefined, ConfigurationTarget.Global);
});
});

View File

@ -12,10 +12,7 @@ import { closeAllEditors, withRandomFileEditor } from './testUtils';
const completionProvider = new DefaultCompletionItemProvider();
suite('Tests for completion in CSS embedded in HTML', () => {
teardown(() => {
// close all editors
return closeAllEditors;
});
teardown(closeAllEditors);
test('style attribute & attribute value in html', async () => {
await testHtmlCompletionProvider('<div style="|"', [{ label: 'padding: ;' }]);
@ -81,10 +78,10 @@ function testHtmlCompletionProvider(contents: string, expectedItems: TestComplet
assert.ok(match, `Didn't find completion item with label ${eItem.label}`);
if (match) {
assert.equal(match.detail, 'Emmet Abbreviation', `Match needs to come from Emmet`);
assert.strictEqual(match.detail, 'Emmet Abbreviation', `Match needs to come from Emmet`);
if (eItem.documentation) {
assert.equal(match.documentation, eItem.documentation, `Emmet completion Documentation doesn't match`);
assert.strictEqual(match.documentation, eItem.documentation, `Emmet completion Documentation doesn't match`);
}
}
});
@ -122,10 +119,10 @@ function testCssCompletionProvider(contents: string, expectedItems: TestCompleti
assert.ok(match, `Didn't find completion item with label ${eItem.label}`);
if (match) {
assert.equal(match.detail, 'Emmet Abbreviation', `Match needs to come from Emmet`);
assert.strictEqual(match.detail, 'Emmet Abbreviation', `Match needs to come from Emmet`);
if (eItem.documentation) {
assert.equal(match.documentation, eItem.documentation, `Emmet completion Documentation doesn't match`);
assert.strictEqual(match.documentation, eItem.documentation, `Emmet completion Documentation doesn't match`);
}
}
});

View File

@ -59,7 +59,7 @@ suite('Tests for Expand Abbreviations (CSS)', () => {
return withRandomFileEditor(cssContents, 'css', (editor, _) => {
editor.selections = [new Selection(3, 1, 3, 6), new Selection(5, 1, 5, 6)];
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), cssContents.replace(/pos:f/g, 'position: fixed;'));
assert.strictEqual(editor.document.getText(), cssContents.replace(/pos:f/g, 'position: fixed;'));
return Promise.resolve();
});
});
@ -78,11 +78,11 @@ suite('Tests for Expand Abbreviations (CSS)', () => {
return withRandomFileEditor(testContent, 'css', (editor, _) => {
editor.selection = new Selection(3, 4, 3, 4);
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), testContent);
assert.strictEqual(editor.document.getText(), testContent);
const cancelSrc = new CancellationTokenSource();
const completionPromise = completionProvider.provideCompletionItems(editor.document, new Position(2, 10), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
if (completionPromise) {
assert.equal(1, 2, `Invalid completion at property value`);
assert.strictEqual(1, 2, `Invalid completion at property value`);
}
return Promise.resolve();
});
@ -101,11 +101,11 @@ nav#
return withRandomFileEditor(testContent, 'css', (editor, _) => {
editor.selection = new Selection(5, 4, 5, 4);
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), testContent);
assert.strictEqual(editor.document.getText(), testContent);
const cancelSrc = new CancellationTokenSource();
const completionPromise = completionProvider.provideCompletionItems(editor.document, new Position(2, 10), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
if (completionPromise) {
assert.equal(1, 2, `Invalid completion at property value`);
assert.strictEqual(1, 2, `Invalid completion at property value`);
}
return Promise.resolve();
});
@ -123,11 +123,11 @@ nav#
return withRandomFileEditor(testContent, 'css', (editor, _) => {
editor.selection = new Selection(2, 10, 2, 10);
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), testContent);
assert.strictEqual(editor.document.getText(), testContent);
const cancelSrc = new CancellationTokenSource();
const completionPromise = completionProvider.provideCompletionItems(editor.document, new Position(2, 10), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
if (completionPromise) {
assert.equal(1, 2, `Invalid completion at property value`);
assert.strictEqual(1, 2, `Invalid completion at property value`);
}
return Promise.resolve();
});
@ -140,11 +140,11 @@ nav#
return withRandomFileEditor(testContent, 'css', (editor, _) => {
editor.selection = new Selection(0, 30, 0, 30);
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), testContent);
assert.strictEqual(editor.document.getText(), testContent);
const cancelSrc = new CancellationTokenSource();
const completionPromise = completionProvider.provideCompletionItems(editor.document, new Position(0, 30), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
if (completionPromise) {
assert.equal(1, 2, `Invalid completion at property value`);
assert.strictEqual(1, 2, `Invalid completion at property value`);
}
return Promise.resolve();
});
@ -165,18 +165,18 @@ nav#
const completionPromise2 = completionProvider.provideCompletionItems(editor.document, new Position(2, 14), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
if (!completionPromise1 || !completionPromise2) {
assert.equal(1, 2, `Completion promise wasnt returned`);
assert.strictEqual(1, 2, `Completion promise wasnt returned`);
return Promise.resolve();
}
const callBack = (completionList: CompletionList, expandedText: string) => {
if (!completionList.items || !completionList.items.length) {
assert.equal(1, 2, `Empty Completions`);
assert.strictEqual(1, 2, `Empty Completions`);
return;
}
const emmetCompletionItem = completionList.items[0];
assert.equal(emmetCompletionItem.label, expandedText, `Label of completion item doesnt match.`);
assert.equal((<string>emmetCompletionItem.documentation || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
assert.strictEqual(emmetCompletionItem.label, expandedText, `Label of completion item doesnt match.`);
assert.strictEqual((<string>emmetCompletionItem.documentation || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
};
return Promise.all<CompletionList>([completionPromise1, completionPromise2]).then(([result1, result2]) => {
@ -184,7 +184,7 @@ nav#
callBack(result2, '!important');
editor.selections = [new Selection(2, 12, 2, 12), new Selection(2, 14, 2, 14)];
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), testContent.replace('#12', '#121212').replace('!', '!important'));
assert.strictEqual(editor.document.getText(), testContent.replace('#12', '#121212').replace('!', '!important'));
});
});
});
@ -201,11 +201,11 @@ nav#
return withRandomFileEditor(testContent, 'css', (editor, _) => {
editor.selection = new Selection(3, 10, 3, 10);
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), testContent);
assert.strictEqual(editor.document.getText(), testContent);
const cancelSrc = new CancellationTokenSource();
const completionPromise = completionProvider.provideCompletionItems(editor.document, new Position(3, 10), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
if (completionPromise) {
assert.equal(1, 2, `Invalid completion at property value`);
assert.strictEqual(1, 2, `Invalid completion at property value`);
}
return Promise.resolve();
});
@ -226,18 +226,18 @@ nav#
const completionPromise2 = completionProvider.provideCompletionItems(editor.document, new Position(3, 14), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
if (!completionPromise1 || !completionPromise2) {
assert.equal(1, 2, `Completion promise wasnt returned`);
assert.strictEqual(1, 2, `Completion promise wasnt returned`);
return Promise.resolve();
}
const callBack = (completionList: CompletionList, expandedText: string) => {
if (!completionList.items || !completionList.items.length) {
assert.equal(1, 2, `Empty Completions`);
assert.strictEqual(1, 2, `Empty Completions`);
return;
}
const emmetCompletionItem = completionList.items[0];
assert.equal(emmetCompletionItem.label, expandedText, `Label of completion item doesnt match.`);
assert.equal((<string>emmetCompletionItem.documentation || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
assert.strictEqual(emmetCompletionItem.label, expandedText, `Label of completion item doesnt match.`);
assert.strictEqual((<string>emmetCompletionItem.documentation || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
};
return Promise.all<CompletionList>([completionPromise1, completionPromise2]).then(([result1, result2]) => {
@ -245,7 +245,7 @@ nav#
callBack(result2, '!important');
editor.selections = [new Selection(3, 12, 3, 12), new Selection(3, 14, 3, 14)];
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), testContent.replace('#12', '#121212').replace('!', '!important'));
assert.strictEqual(editor.document.getText(), testContent.replace('#12', '#121212').replace('!', '!important'));
});
});
});
@ -261,11 +261,11 @@ nav#
return withRandomFileEditor(testContent, 'css', (editor, _) => {
editor.selection = new Selection(2, 10, 2, 10);
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), testContent);
assert.strictEqual(editor.document.getText(), testContent);
const cancelSrc = new CancellationTokenSource();
const completionPromise = completionProvider.provideCompletionItems(editor.document, new Position(2, 10), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
if (completionPromise) {
assert.equal(1, 2, `Invalid completion at property value`);
assert.strictEqual(1, 2, `Invalid completion at property value`);
}
return Promise.resolve();
});
@ -285,18 +285,18 @@ nav#
const completionPromise2 = completionProvider.provideCompletionItems(editor.document, new Position(2, 14), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
if (!completionPromise1 || !completionPromise2) {
assert.equal(1, 2, `Completion promise wasnt returned`);
assert.strictEqual(1, 2, `Completion promise wasnt returned`);
return Promise.resolve();
}
const callBack = (completionList: CompletionList, expandedText: string) => {
if (!completionList.items || !completionList.items.length) {
assert.equal(1, 2, `Empty Completions`);
assert.strictEqual(1, 2, `Empty Completions`);
return;
}
const emmetCompletionItem = completionList.items[0];
assert.equal(emmetCompletionItem.label, expandedText, `Label of completion item doesnt match.`);
assert.equal((<string>emmetCompletionItem.documentation || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
assert.strictEqual(emmetCompletionItem.label, expandedText, `Label of completion item doesnt match.`);
assert.strictEqual((<string>emmetCompletionItem.documentation || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
};
return Promise.all<CompletionList>([completionPromise1, completionPromise2]).then(([result1, result2]) => {
@ -304,7 +304,7 @@ nav#
callBack(result2, '!important');
editor.selections = [new Selection(2, 12, 2, 12), new Selection(2, 14, 2, 14)];
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), testContent.replace('#12', '#121212').replace('!', '!important'));
assert.strictEqual(editor.document.getText(), testContent.replace('#12', '#121212').replace('!', '!important'));
});
});
});
@ -320,11 +320,11 @@ nav#
return withRandomFileEditor(testContent, 'css', (editor, _) => {
editor.selection = new Selection(2, 2, 2, 2);
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), testContent);
assert.strictEqual(editor.document.getText(), testContent);
const cancelSrc = new CancellationTokenSource();
const completionPromise = completionProvider.provideCompletionItems(editor.document, new Position(2, 2), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
if (completionPromise) {
assert.equal(1, 2, `Invalid completion of hex color at property name`);
assert.strictEqual(1, 2, `Invalid completion of hex color at property name`);
}
return Promise.resolve();
});
@ -342,19 +342,19 @@ nav#
const completionPromise1 = completionProvider.provideCompletionItems(editor.document, new Position(3, 6), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
const completionPromise2 = completionProvider.provideCompletionItems(editor.document, new Position(5, 6), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
if (!completionPromise1 || !completionPromise2) {
assert.equal(1, 2, `Problem with expanding pos:f`);
assert.strictEqual(1, 2, `Problem with expanding pos:f`);
return Promise.resolve();
}
const callBack = (completionList: CompletionList) => {
if (!completionList.items || !completionList.items.length) {
assert.equal(1, 2, `Problem with expanding pos:f`);
assert.strictEqual(1, 2, `Problem with expanding pos:f`);
return;
}
const emmetCompletionItem = completionList.items[0];
assert.equal(emmetCompletionItem.label, expandedText, `Label of completion item doesnt match.`);
assert.equal((<string>emmetCompletionItem.documentation || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
assert.equal(emmetCompletionItem.filterText, abbreviation, `FilterText of completion item doesnt match.`);
assert.strictEqual(emmetCompletionItem.label, expandedText, `Label of completion item doesnt match.`);
assert.strictEqual((<string>emmetCompletionItem.documentation || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
assert.strictEqual(emmetCompletionItem.filterText, abbreviation, `FilterText of completion item doesnt match.`);
};
return Promise.all<CompletionList>([completionPromise1, completionPromise2]).then(([result1, result2]) => {
@ -374,7 +374,7 @@ nav#
new Selection(14, 5, 14, 5)
];
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), scssContents.replace(/p(\d\d)/g, 'padding: $1px;'));
assert.strictEqual(editor.document.getText(), scssContents.replace(/p(\d\d)/g, 'padding: $1px;'));
return Promise.resolve();
});
});
@ -390,16 +390,16 @@ nav#
const completionPromise3 = completionProvider.provideCompletionItems(editor.document, new Position(11, 4), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
const completionPromise4 = completionProvider.provideCompletionItems(editor.document, new Position(14, 5), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
if (!completionPromise1) {
assert.equal(1, 2, `Problem with expanding padding abbreviations at line 3 col 4`);
assert.strictEqual(1, 2, `Problem with expanding padding abbreviations at line 3 col 4`);
}
if (!completionPromise2) {
assert.equal(1, 2, `Problem with expanding padding abbreviations at line 5 col 5`);
assert.strictEqual(1, 2, `Problem with expanding padding abbreviations at line 5 col 5`);
}
if (!completionPromise3) {
assert.equal(1, 2, `Problem with expanding padding abbreviations at line 11 col 4`);
assert.strictEqual(1, 2, `Problem with expanding padding abbreviations at line 11 col 4`);
}
if (!completionPromise4) {
assert.equal(1, 2, `Problem with expanding padding abbreviations at line 14 col 5`);
assert.strictEqual(1, 2, `Problem with expanding padding abbreviations at line 14 col 5`);
}
if (!completionPromise1 || !completionPromise2 || !completionPromise3 || !completionPromise4) {
@ -408,13 +408,13 @@ nav#
const callBack = (completionList: CompletionList, abbreviation: string, expandedText: string) => {
if (!completionList.items || !completionList.items.length) {
assert.equal(1, 2, `Problem with expanding m10`);
assert.strictEqual(1, 2, `Problem with expanding m10`);
return;
}
const emmetCompletionItem = completionList.items[0];
assert.equal(emmetCompletionItem.label, expandedText, `Label of completion item doesnt match.`);
assert.equal((<string>emmetCompletionItem.documentation || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
assert.equal(emmetCompletionItem.filterText, abbreviation, `FilterText of completion item doesnt match.`);
assert.strictEqual(emmetCompletionItem.label, expandedText, `Label of completion item doesnt match.`);
assert.strictEqual((<string>emmetCompletionItem.documentation || '').replace(/\|/g, ''), expandedText, `Docs of completion item doesnt match.`);
assert.strictEqual(emmetCompletionItem.filterText, abbreviation, `FilterText of completion item doesnt match.`);
};
return Promise.all<CompletionList>([completionPromise1, completionPromise2, completionPromise3, completionPromise4]).then(([result1, result2, result3, result4]) => {
@ -445,7 +445,7 @@ m10
new Selection(5, 15, 5, 15) // in the value part of property value
];
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), scssContentsNoExpand);
assert.strictEqual(editor.document.getText(), scssContentsNoExpand);
return Promise.resolve();
});
});
@ -467,7 +467,7 @@ m10
const cancelSrc = new CancellationTokenSource();
let completionPromise = completionProvider.provideCompletionItems(editor.document, editor.selection.active, cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
if (completionPromise) {
assert.equal(1, 2, `m10 gets expanded in invalid location (outside rule)`);
assert.strictEqual(1, 2, `m10 gets expanded in invalid location (outside rule)`);
}
editor.selection = new Selection(5, 15, 5, 15); // in the value part of property value
@ -475,7 +475,7 @@ m10
if (completionPromise) {
return completionPromise.then((completionList: CompletionList | undefined) => {
if (completionList && completionList.items && completionList.items.length > 0) {
assert.equal(1, 2, `m10 gets expanded in invalid location (n the value part of property value)`);
assert.strictEqual(1, 2, `m10 gets expanded in invalid location (n the value part of property value)`);
}
return Promise.resolve();
});
@ -484,19 +484,18 @@ m10
});
});
});
test('Skip when typing property values when there is a nested rule in the next line (SCSS)', () => {
return withRandomFileEditor(scssContents, 'scss', (editor, _) => {
editor.selection = new Selection(19, 10, 19, 10);
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), scssContents);
const cancelSrc = new CancellationTokenSource();
const completionPromise = completionProvider.provideCompletionItems(editor.document, new Position(19, 10), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
if (completionPromise) {
assert.equal(1, 2, `Invalid completion at property value`);
}
return Promise.resolve();
test('Skip when typing property values when there is a nested rule in the next line (SCSS)', () => {
return withRandomFileEditor(scssContents, 'scss', (editor, _) => {
editor.selection = new Selection(19, 10, 19, 10);
return expandEmmetAbbreviation(null).then(() => {
assert.strictEqual(editor.document.getText(), scssContents);
const cancelSrc = new CancellationTokenSource();
const completionPromise = completionProvider.provideCompletionItems(editor.document, new Position(19, 10), cancelSrc.token, { triggerKind: CompletionTriggerKind.Invoke });
if (completionPromise) {
assert.strictEqual(1, 2, `Invalid completion at property value`);
}
return Promise.resolve();
});
});
});
});

View File

@ -352,17 +352,16 @@ suite('Tests for Next/Previous Select/Edit point and Balance actions', () => {
});
function testSelection(selection: Selection, startChar: number, startline: number, endChar?: number, endLine?: number) {
assert.equal(selection.anchor.line, startline);
assert.equal(selection.anchor.character, startChar);
assert.strictEqual(selection.anchor.line, startline);
assert.strictEqual(selection.anchor.character, startChar);
if (!endLine && endLine !== 0) {
assert.equal(selection.isSingleLine, true);
assert.strictEqual(selection.isSingleLine, true);
} else {
assert.equal(selection.active.line, endLine);
assert.strictEqual(selection.active.line, endLine);
}
if (!endChar && endChar !== 0) {
assert.equal(selection.isEmpty, true);
assert.strictEqual(selection.isEmpty, true);
} else {
assert.equal(selection.active.character, endChar);
assert.strictEqual(selection.active.character, endChar);
}
}

View File

@ -28,7 +28,7 @@ suite('Tests for Increment/Decrement Emmet Commands', () => {
return withRandomFileEditor(contents, 'txt', async (editor, doc) => {
editor.selections = [new Selection(1, 7, 1, 10), new Selection(2, 7, 2, 10)];
await incrementDecrement(1);
assert.equal(doc.getText(), contents.replace('123', '124').replace('999', '1000'));
assert.strictEqual(doc.getText(), contents.replace('123', '124').replace('999', '1000'));
return Promise.resolve();
});
});
@ -37,7 +37,7 @@ suite('Tests for Increment/Decrement Emmet Commands', () => {
return withRandomFileEditor(contents, 'txt', async (editor, doc) => {
editor.selections = [new Selection(1, 7, 1, 10), new Selection(2, 7, 2, 10)];
await incrementDecrement(10);
assert.equal(doc.getText(), contents.replace('123', '133').replace('999', '1009'));
assert.strictEqual(doc.getText(), contents.replace('123', '133').replace('999', '1009'));
return Promise.resolve();
});
});
@ -46,7 +46,7 @@ suite('Tests for Increment/Decrement Emmet Commands', () => {
return withRandomFileEditor(contents, 'txt', async (editor, doc) => {
editor.selections = [new Selection(1, 7, 1, 13), new Selection(2, 7, 2, 12)];
await incrementDecrement(0.1);
assert.equal(doc.getText(), contents.replace('123.43', '123.53').replace('999.9', '1000'));
assert.strictEqual(doc.getText(), contents.replace('123.43', '123.53').replace('999.9', '1000'));
return Promise.resolve();
});
});
@ -55,7 +55,7 @@ suite('Tests for Increment/Decrement Emmet Commands', () => {
return withRandomFileEditor(contents, 'txt', async (editor, doc) => {
editor.selections = [new Selection(1, 7, 1, 10), new Selection(3, 7, 3, 10)];
await incrementDecrement(-1);
assert.equal(doc.getText(), contents.replace('123', '122').replace('100', '99'));
assert.strictEqual(doc.getText(), contents.replace('123', '122').replace('100', '99'));
return Promise.resolve();
});
});
@ -64,7 +64,7 @@ suite('Tests for Increment/Decrement Emmet Commands', () => {
return withRandomFileEditor(contents, 'txt', async (editor, doc) => {
editor.selections = [new Selection(1, 7, 1, 10), new Selection(3, 7, 3, 10)];
await incrementDecrement(-10);
assert.equal(doc.getText(), contents.replace('123', '113').replace('100', '90'));
assert.strictEqual(doc.getText(), contents.replace('123', '113').replace('100', '90'));
return Promise.resolve();
});
});
@ -73,8 +73,8 @@ suite('Tests for Increment/Decrement Emmet Commands', () => {
return withRandomFileEditor(contents, 'txt', async (editor, doc) => {
editor.selections = [new Selection(1, 7, 1, 13), new Selection(3, 7, 3, 10)];
await incrementDecrement(-0.1);
assert.equal(doc.getText(), contents.replace('123.43', '123.33').replace('100', '99.9'));
assert.strictEqual(doc.getText(), contents.replace('123.43', '123.33').replace('100', '99.9'));
return Promise.resolve();
});
});
});
});

View File

@ -8,7 +8,7 @@ const testRunner = require('../../../../test/integration/electron/testrunner');
const options: any = {
ui: 'tdd',
color: (!process.env.BUILD_ARTIFACTSTAGINGDIRECTORY && process.platform !== 'win32'),
color: true,
timeout: 60000
};

View File

@ -5,12 +5,13 @@
import 'mocha';
import * as assert from 'assert';
import { withRandomFileEditor } from './testUtils';
import { closeAllEditors, withRandomFileEditor } from './testUtils';
import * as vscode from 'vscode';
import { parsePartialStylesheet, getFlatNode } from '../util';
import { isValidLocationForEmmetAbbreviation } from '../abbreviationActions';
suite('Tests for partial parse of Stylesheets', () => {
teardown(closeAllEditors);
function isValid(doc: vscode.TextDocument, range: vscode.Range, syntax: string): boolean {
const rootNode = parsePartialStylesheet(doc, range.end);
@ -43,10 +44,10 @@ p {
];
rangesForEmmet.forEach(range => {
assert.equal(isValid(doc, range, 'css'), true);
assert.strictEqual(isValid(doc, range, 'css'), true);
});
rangesNotEmmet.forEach(range => {
assert.equal(isValid(doc, range, 'css'), false);
assert.strictEqual(isValid(doc, range, 'css'), false);
});
return Promise.resolve();
@ -73,7 +74,7 @@ dn {
new vscode.Range(7, 2, 7, 4) // bg after ending of badly constructed block
];
rangesNotEmmet.forEach(range => {
assert.equal(isValid(doc, range, 'scss'), false);
assert.strictEqual(isValid(doc, range, 'scss'), false);
});
return Promise.resolve();
});
@ -108,10 +109,10 @@ comment */
new vscode.Range(10, 2, 10, 3) // p after ending of block
];
rangesForEmmet.forEach(range => {
assert.equal(isValid(doc, range, 'css'), true);
assert.strictEqual(isValid(doc, range, 'css'), true);
});
rangesNotEmmet.forEach(range => {
assert.equal(isValid(doc, range, 'css'), false);
assert.strictEqual(isValid(doc, range, 'css'), false);
});
return Promise.resolve();
});
@ -143,10 +144,10 @@ comment */
new vscode.Range(6, 3, 6, 4) // In selector
];
rangesForEmmet.forEach(range => {
assert.equal(isValid(doc, range, 'scss'), true);
assert.strictEqual(isValid(doc, range, 'scss'), true);
});
rangesNotEmmet.forEach(range => {
assert.equal(isValid(doc, range, 'scss'), false);
assert.strictEqual(isValid(doc, range, 'scss'), false);
});
return Promise.resolve();
});
@ -175,10 +176,10 @@ comment */
new vscode.Range(1, 66, 1, 68) // Outside any ruleset
];
rangesForEmmet.forEach(range => {
assert.equal(isValid(doc, range, 'scss'), true);
assert.strictEqual(isValid(doc, range, 'scss'), true);
});
rangesNotEmmet.forEach(range => {
assert.equal(isValid(doc, range, 'scss'), false);
assert.strictEqual(isValid(doc, range, 'scss'), false);
});
return Promise.resolve();
});
@ -210,10 +211,10 @@ p.#{dn} {
new vscode.Range(3, 1, 3, 2), // # inside ruleset
];
rangesForEmmet.forEach(range => {
assert.equal(isValid(doc, range, 'scss'), true);
assert.strictEqual(isValid(doc, range, 'scss'), true);
});
rangesNotEmmet.forEach(range => {
assert.equal(isValid(doc, range, 'scss'), false);
assert.strictEqual(isValid(doc, range, 'scss'), false);
});
return Promise.resolve();
});
@ -248,10 +249,10 @@ ment */{
new vscode.Range(6, 3, 6, 4) // In c inside block comment
];
rangesForEmmet.forEach(range => {
assert.equal(isValid(doc, range, 'scss'), true);
assert.strictEqual(isValid(doc, range, 'scss'), true);
});
rangesNotEmmet.forEach(range => {
assert.equal(isValid(doc, range, 'scss'), false);
assert.strictEqual(isValid(doc, range, 'scss'), false);
});
return Promise.resolve();
});

View File

@ -50,7 +50,7 @@ suite('Tests for Emmet: Reflect CSS Value command', () => {
return withRandomFileEditor(cssContents, '.css', (editor, doc) => {
editor.selections = [new Selection(5, 10, 5, 10)];
return reflectCssValue().then(() => {
assert.equal(doc.getText(), cssContents.replace(/\(50deg\)/g, '(20deg)'));
assert.strictEqual(doc.getText(), cssContents.replace(/\(50deg\)/g, '(20deg)'));
return Promise.resolve();
});
});
@ -60,7 +60,7 @@ suite('Tests for Emmet: Reflect CSS Value command', () => {
return withRandomFileEditor(cssContents, '.css', (editor, doc) => {
editor.selections = [new Selection(5, 2, 5, 32)];
return reflectCssValue().then(() => {
assert.equal(doc.getText(), cssContents.replace(/\(50deg\)/g, '(20deg)'));
assert.strictEqual(doc.getText(), cssContents.replace(/\(50deg\)/g, '(20deg)'));
return Promise.resolve();
});
});
@ -70,7 +70,7 @@ suite('Tests for Emmet: Reflect CSS Value command', () => {
return withRandomFileEditor(htmlContents, '.html', (editor, doc) => {
editor.selections = [new Selection(7, 20, 7, 20)];
return reflectCssValue().then(() => {
assert.equal(doc.getText(), htmlContents.replace(/\(50deg\)/g, '(20deg)'));
assert.strictEqual(doc.getText(), htmlContents.replace(/\(50deg\)/g, '(20deg)'));
return Promise.resolve();
});
});
@ -80,10 +80,10 @@ suite('Tests for Emmet: Reflect CSS Value command', () => {
return withRandomFileEditor(htmlContents, '.html', (editor, doc) => {
editor.selections = [new Selection(7, 4, 7, 34)];
return reflectCssValue().then(() => {
assert.equal(doc.getText(), htmlContents.replace(/\(50deg\)/g, '(20deg)'));
assert.strictEqual(doc.getText(), htmlContents.replace(/\(50deg\)/g, '(20deg)'));
return Promise.resolve();
});
});
});
});
});

View File

@ -14,10 +14,7 @@ import { splitJoinTag } from '../splitJoinTag';
import { mergeLines } from '../mergeLines';
suite('Tests for Emmet actions on html tags', () => {
teardown(() => {
// close all editors
return closeAllEditors;
});
teardown(closeAllEditors);
const contents = `
<div class="hello">
@ -60,7 +57,7 @@ suite('Tests for Emmet actions on html tags', () => {
];
return updateTag('section')!.then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
});
@ -85,7 +82,7 @@ suite('Tests for Emmet actions on html tags', () => {
];
return updateTag('section')!.then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
});
@ -109,7 +106,7 @@ suite('Tests for Emmet actions on html tags', () => {
];
return updateTag('section')!.then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
});
@ -136,7 +133,7 @@ suite('Tests for Emmet actions on html tags', () => {
];
return removeTag()!.then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
});
@ -161,7 +158,7 @@ suite('Tests for Emmet actions on html tags', () => {
];
return removeTag()!.then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
});
@ -185,7 +182,7 @@ suite('Tests for Emmet actions on html tags', () => {
];
return removeTag()!.then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
});
@ -211,7 +208,7 @@ suite('Tests for Emmet actions on html tags', () => {
];
return splitJoinTag()!.then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
});
@ -235,7 +232,7 @@ suite('Tests for Emmet actions on html tags', () => {
];
return splitJoinTag()!.then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
});
@ -259,7 +256,7 @@ suite('Tests for Emmet actions on html tags', () => {
];
return splitJoinTag()!.then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
});
@ -285,7 +282,7 @@ suite('Tests for Emmet actions on html tags', () => {
];
return splitJoinTag()!.then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return workspace.getConfiguration('emmet').update('syntaxProfiles', oldValueForSyntaxProfiles ? oldValueForSyntaxProfiles.globalValue : undefined, ConfigurationTarget.Global);
});
});
@ -308,10 +305,10 @@ suite('Tests for Emmet actions on html tags', () => {
matchTag();
editor.selections.forEach(selection => {
assert.equal(selection.active.line, 8);
assert.equal(selection.active.character, 3);
assert.equal(selection.anchor.line, 8);
assert.equal(selection.anchor.character, 3);
assert.strictEqual(selection.active.line, 8);
assert.strictEqual(selection.active.character, 3);
assert.strictEqual(selection.anchor.line, 8);
assert.strictEqual(selection.anchor.character, 3);
});
return Promise.resolve();
@ -334,10 +331,10 @@ suite('Tests for Emmet actions on html tags', () => {
matchTag();
editor.selections.forEach(selection => {
assert.equal(selection.active.line, 4);
assert.equal(selection.active.character, 4);
assert.equal(selection.anchor.line, 4);
assert.equal(selection.anchor.character, 4);
assert.strictEqual(selection.active.line, 4);
assert.strictEqual(selection.active.character, 4);
assert.strictEqual(selection.anchor.line, 4);
assert.strictEqual(selection.anchor.character, 4);
});
return Promise.resolve();
@ -360,7 +357,7 @@ suite('Tests for Emmet actions on html tags', () => {
];
return mergeLines()!.then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
});
@ -379,7 +376,7 @@ suite('Tests for Emmet actions on html tags', () => {
];
return mergeLines()!.then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
});
@ -394,7 +391,7 @@ suite('Tests for Emmet actions on html tags', () => {
];
return mergeLines()!.then(() => {
assert.equal(doc.getText(), contents);
assert.strictEqual(doc.getText(), contents);
return Promise.resolve();
});
});

View File

@ -1,3 +0,0 @@
{
"editor.minimap.enabled": false // see https://github.com/microsoft/vscode/issues/115747
}

View File

@ -1 +0,0 @@
DO NOT DELETE, USED BY INTEGRATION TESTS

View File

@ -48,7 +48,6 @@ export function deleteFile(file: vscode.Uri): Thenable<boolean> {
export function closeAllEditors(): Thenable<any> {
return vscode.commands.executeCommand('workbench.action.closeAllEditors');
}
export function withRandomFileEditor(initialContents: string, fileExtension: string = 'txt', run: (editor: vscode.TextEditor, doc: vscode.TextDocument) => Thenable<void>): Thenable<boolean> {
@ -67,4 +66,4 @@ export function withRandomFileEditor(initialContents: string, fileExtension: str
});
});
});
}
}

View File

@ -79,7 +79,7 @@ suite('Tests for Toggle Comment action from Emmet (HTML)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
});
@ -120,7 +120,7 @@ suite('Tests for Toggle Comment action from Emmet (HTML)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
});
@ -158,7 +158,7 @@ suite('Tests for Toggle Comment action from Emmet (HTML)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
});
@ -196,7 +196,7 @@ suite('Tests for Toggle Comment action from Emmet (HTML)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
});
@ -241,7 +241,7 @@ suite('Tests for Toggle Comment action from Emmet (HTML)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
@ -272,7 +272,7 @@ suite('Tests for Toggle Comment action from Emmet (HTML)', () => {
new Selection(4, 18, 4, 18), // cursor inside the noncommented span
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
});
@ -315,9 +315,9 @@ suite('Tests for Toggle Comment action from Emmet (CSS)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return toggleComment().then(() => {
assert.equal(doc.getText(), contents);
assert.strictEqual(doc.getText(), contents);
return Promise.resolve();
});
});
@ -345,9 +345,9 @@ suite('Tests for Toggle Comment action from Emmet (CSS)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
//return toggleComment().then(() => {
//assert.equal(doc.getText(), contents);
//assert.strictEqual(doc.getText(), contents);
return Promise.resolve();
//});
});
@ -376,9 +376,9 @@ suite('Tests for Toggle Comment action from Emmet (CSS)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return toggleComment().then(() => {
assert.equal(doc.getText(), contents);
assert.strictEqual(doc.getText(), contents);
return Promise.resolve();
});
});
@ -404,9 +404,9 @@ suite('Tests for Toggle Comment action from Emmet (CSS)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return toggleComment().then(() => {
assert.equal(doc.getText(), contents);
assert.strictEqual(doc.getText(), contents);
return Promise.resolve();
});
});
@ -432,9 +432,9 @@ suite('Tests for Toggle Comment action from Emmet (CSS)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return toggleComment().then(() => {
assert.equal(doc.getText(), contents);
assert.strictEqual(doc.getText(), contents);
return Promise.resolve();
});
});
@ -460,9 +460,9 @@ suite('Tests for Toggle Comment action from Emmet (CSS)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return toggleComment().then(() => {
assert.equal(doc.getText(), contents);
assert.strictEqual(doc.getText(), contents);
return Promise.resolve();
});
});
@ -488,9 +488,9 @@ suite('Tests for Toggle Comment action from Emmet (CSS)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return toggleComment().then(() => {
assert.equal(doc.getText(), contents);
assert.strictEqual(doc.getText(), contents);
return Promise.resolve();
});
});
@ -517,9 +517,9 @@ suite('Tests for Toggle Comment action from Emmet (CSS)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return toggleComment().then(() => {
assert.equal(doc.getText(), contents);
assert.strictEqual(doc.getText(), contents);
return Promise.resolve();
});
});
@ -568,9 +568,9 @@ suite('Tests for Toggle Comment action from Emmet in nested css (SCSS)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return toggleComment().then(() => {
assert.equal(doc.getText(), contents);
assert.strictEqual(doc.getText(), contents);
return Promise.resolve();
});
});
@ -599,9 +599,9 @@ suite('Tests for Toggle Comment action from Emmet in nested css (SCSS)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return toggleComment().then(() => {
assert.equal(doc.getText(), contents);
assert.strictEqual(doc.getText(), contents);
return Promise.resolve();
});
});
@ -629,9 +629,9 @@ suite('Tests for Toggle Comment action from Emmet in nested css (SCSS)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
//return toggleComment().then(() => {
// assert.equal(doc.getText(), contents);
// assert.strictEqual(doc.getText(), contents);
return Promise.resolve();
//});
});
@ -659,9 +659,9 @@ suite('Tests for Toggle Comment action from Emmet in nested css (SCSS)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return toggleComment().then(() => {
assert.equal(doc.getText(), contents);
assert.strictEqual(doc.getText(), contents);
return Promise.resolve();
});
});
@ -689,9 +689,9 @@ suite('Tests for Toggle Comment action from Emmet in nested css (SCSS)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return toggleComment().then(() => {
assert.equal(doc.getText(), contents);
assert.strictEqual(doc.getText(), contents);
return Promise.resolve();
});
});
@ -717,9 +717,9 @@ suite('Tests for Toggle Comment action from Emmet in nested css (SCSS)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return toggleComment().then(() => {
assert.equal(doc.getText(), contents);
assert.strictEqual(doc.getText(), contents);
return Promise.resolve();
});
});
@ -743,9 +743,9 @@ suite('Tests for Toggle Comment action from Emmet in nested css (SCSS)', () => {
];
return toggleComment().then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return toggleComment().then(() => {
assert.equal(doc.getText(), contents);
assert.strictEqual(doc.getText(), contents);
return Promise.resolve();
});
});

View File

@ -55,7 +55,7 @@ suite('Tests for Emmet actions on html tags', () => {
];
return updateImageSize()!.then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
});
@ -112,7 +112,7 @@ suite('Tests for Emmet actions on html tags', () => {
];
return updateImageSize()!.then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
});
@ -141,7 +141,7 @@ suite('Tests for Emmet actions on html tags', () => {
];
return updateImageSize()!.then(() => {
assert.equal(doc.getText(), expectedContents);
assert.strictEqual(doc.getText(), expectedContents);
return Promise.resolve();
});
});

View File

@ -398,12 +398,12 @@ function testWrapWithAbbreviation(selections: Selection[], abbreviation: string,
editor.selections = selections;
const promise = wrapWithAbbreviation({ abbreviation });
if (!promise) {
assert.equal(1, 2, 'Wrap with Abbreviation returned undefined.');
assert.strictEqual(1, 2, 'Wrap with Abbreviation returned undefined.');
return Promise.resolve();
}
return promise.then(() => {
assert.equal(editor.document.getText(), expectedContents);
assert.strictEqual(editor.document.getText(), expectedContents);
return Promise.resolve();
});
});
@ -414,12 +414,12 @@ function testWrapIndividualLinesWithAbbreviation(selections: Selection[], abbrev
editor.selections = selections;
const promise = wrapWithAbbreviation({ abbreviation });
if (!promise) {
assert.equal(1, 2, 'Wrap individual lines with Abbreviation returned undefined.');
assert.strictEqual(1, 2, 'Wrap individual lines with Abbreviation returned undefined.');
return Promise.resolve();
}
return promise.then(() => {
assert.equal(editor.document.getText(), expectedContents);
assert.strictEqual(editor.document.getText(), expectedContents);
return Promise.resolve();
});
});

View File

@ -42,17 +42,13 @@ export function updateEmmetExtensionsPath(forceRefresh: boolean = false) {
}
if (forceRefresh || _currentExtensionsPath !== extensionsPath) {
_currentExtensionsPath = extensionsPath;
if (!vscode.workspace.workspaceFolders || vscode.workspace.workspaceFolders.length === 0) {
return;
} else {
const rootPath = vscode.workspace.workspaceFolders[0].uri;
const fileSystem = vscode.workspace.fs;
helper.updateExtensionsPath(extensionsPath, fileSystem, rootPath, _homeDir).catch(err => {
if (Array.isArray(extensionsPath) && extensionsPath.length) {
vscode.window.showErrorMessage(err.message);
}
});
}
const rootPath = vscode.workspace.workspaceFolders?.length ? vscode.workspace.workspaceFolders[0].uri : undefined;
const fileSystem = vscode.workspace.fs;
helper.updateExtensionsPath(extensionsPath, fileSystem, rootPath, _homeDir).catch(err => {
if (Array.isArray(extensionsPath) && extensionsPath.length) {
vscode.window.showErrorMessage(err.message);
}
});
}
}
@ -88,19 +84,19 @@ export function migrateEmmetExtensionsPath() {
* Mapping between languages that support Emmet and completion trigger characters
*/
export const LANGUAGE_MODES: { [id: string]: string[] } = {
'html': ['!', '.', '}', ':', '*', '$', ']', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
'jade': ['!', '.', '}', ':', '*', '$', ']', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
'slim': ['!', '.', '}', ':', '*', '$', ']', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
'haml': ['!', '.', '}', ':', '*', '$', ']', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
'xml': ['.', '}', '*', '$', ']', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
'xsl': ['!', '.', '}', '*', '$', ']', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
'html': ['!', '.', '}', ':', '*', '$', ']', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
'jade': ['!', '.', '}', ':', '*', '$', ']', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
'slim': ['!', '.', '}', ':', '*', '$', ']', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
'haml': ['!', '.', '}', ':', '*', '$', ']', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
'xml': ['.', '}', '*', '$', ']', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
'xsl': ['!', '.', '}', '*', '$', '/', ']', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
'css': [':', '!', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
'scss': [':', '!', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
'sass': [':', '!', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
'less': [':', '!', '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
'stylus': [':', '!', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
'javascriptreact': ['!', '.', '}', '*', '$', ']', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
'typescriptreact': ['!', '.', '}', '*', '$', ']', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
'javascriptreact': ['!', '.', '}', '*', '$', ']', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
'typescriptreact': ['!', '.', '}', '*', '$', ']', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
};
export function isStyleSheet(syntax: string): boolean {
@ -380,32 +376,36 @@ export const allowedMimeTypesInScriptTag = ['text/html', 'text/plain', 'text/x-t
* If position is inside a script tag of type template, then it will be parsed to find the inner HTML node as well
*/
export function getHtmlFlatNode(documentText: string, root: FlatNode | undefined, offset: number, includeNodeBoundary: boolean): HtmlFlatNode | undefined {
const currentNode: HtmlFlatNode | undefined = <HtmlFlatNode | undefined>getFlatNode(root, offset, includeNodeBoundary);
let currentNode: HtmlFlatNode | undefined = <HtmlFlatNode | undefined>getFlatNode(root, offset, includeNodeBoundary);
if (!currentNode) { return; }
const isTemplateScript = currentNode.name === 'script' &&
(currentNode.attributes &&
currentNode.attributes.some(x => x.name.toString() === 'type'
&& allowedMimeTypesInScriptTag.includes(x.value.toString())));
if (isTemplateScript
&& currentNode.open
&& offset > currentNode.open.end
&& (!currentNode.close || offset < currentNode.close.start)) {
// blank out the rest of the document and search for the node within
const beforePadding = ' '.repeat(currentNode.open.end);
const endToUse = currentNode.close ? currentNode.close.start : currentNode.end;
const scriptBodyText = beforePadding + documentText.substring(currentNode.open.end, endToUse);
const innerRoot: HtmlFlatNode = parse(scriptBodyText);
const scriptBodyNode = getHtmlFlatNode(scriptBodyText, innerRoot, offset, includeNodeBoundary);
if (scriptBodyNode) {
scriptBodyNode.parent = currentNode;
currentNode.children.push(scriptBodyNode);
return scriptBodyNode;
}
// If the currentNode is a script one, first set up its subtree and then find HTML node.
if (currentNode.name === 'script' && currentNode.children.length === 0) {
setUpScriptNodeSubtree(documentText, currentNode);
currentNode = <HtmlFlatNode | undefined>getFlatNode(currentNode, offset, includeNodeBoundary) ?? currentNode;
}
return currentNode;
}
export function setUpScriptNodeSubtree(documentText: string, scriptNode: HtmlFlatNode): void {
const isTemplateScript = scriptNode.name === 'script' &&
(scriptNode.attributes &&
scriptNode.attributes.some(x => x.name.toString() === 'type'
&& allowedMimeTypesInScriptTag.includes(x.value.toString())));
if (isTemplateScript
&& scriptNode.open) {
// blank out the rest of the document and generate the subtree.
const beforePadding = ' '.repeat(scriptNode.open.end);
const endToUse = scriptNode.close ? scriptNode.close.start : scriptNode.end;
const scriptBodyText = beforePadding + documentText.substring(scriptNode.open.end, endToUse);
const innerRoot: HtmlFlatNode = parse(scriptBodyText);
innerRoot.children.forEach(child => {
scriptNode.children.push(child);
child.parent = scriptNode;
});
}
}
export function isOffsetInsideOpenOrCloseTag(node: FlatNode, offset: number): boolean {
const htmlNode = node as HtmlFlatNode;
if ((htmlNode.open && offset > htmlNode.open.start && offset < htmlNode.open.end)
@ -583,7 +583,7 @@ export function getEmmetConfiguration(syntax: string) {
) {
syntaxProfiles[syntax] = {
...syntaxProfiles[syntax],
selfClosingStyle: 'xml'
selfClosingStyle: syntax === 'jsx' ? 'xhtml' : 'xml'
};
}
}
@ -657,10 +657,8 @@ export function getEmbeddedCssNodeIfAny(document: vscode.TextDocument, currentNo
const currentHtmlNode = <HtmlFlatNode>currentNode;
if (currentHtmlNode && currentHtmlNode.open && currentHtmlNode.close) {
const offset = document.offsetAt(position);
if (currentHtmlNode.open.end <= offset && offset <= currentHtmlNode.close.start) {
if (currentHtmlNode.name === 'style'
&& currentHtmlNode.open.end < offset
&& currentHtmlNode.close.start > offset) {
if (currentHtmlNode.open.end < offset && offset <= currentHtmlNode.close.start) {
if (currentHtmlNode.name === 'style') {
const buffer = ' '.repeat(currentHtmlNode.open.end) + document.getText().substring(currentHtmlNode.open.end, currentHtmlNode.close.start);
return parseStylesheet(buffer);
}