Skip emmet in selectors #42245

This commit is contained in:
Ramya Achutha Rao 2018-01-27 22:10:50 -08:00
parent 42743ea273
commit 7a5045618e
2 changed files with 31 additions and 0 deletions

View file

@ -237,6 +237,14 @@ export function isValidLocationForEmmetAbbreviation(document: vscode.TextDocumen
return true;
}
// Fix for upstream issue https://github.com/emmetio/css-parser/issues/3
if (currentNode.type === 'property'
&& currentNode.parent
&& currentNode.parent.type !== 'rule'
&& currentNode.parent.type !== 'at-rule') {
return false;
}
// Fix for https://github.com/Microsoft/vscode/issues/34162
// Other than sass, stylus, we can make use of the terminator tokens to validate position
if (syntax !== 'sass' && syntax !== 'stylus' && currentNode.type === 'property') {

View file

@ -65,6 +65,29 @@ suite('Tests for Expand Abbreviations (CSS)', () => {
});
});
test('No emmet when cursor in selector of a rule (CSS)', () => {
const testContent = `
.foo {
margin: 10px;
}
nav#
`;
return withRandomFileEditor(testContent, 'css', (editor, doc) => {
editor.selection = new Selection(5, 4, 5, 4);
return expandEmmetAbbreviation(null).then(() => {
assert.equal(editor.document.getText(), testContent);
const cancelSrc = new CancellationTokenSource();
const completionPromise = completionProvider.provideCompletionItems(editor.document, new Position(2, 10), cancelSrc.token);
if (completionPromise) {
assert.equal(1, 2, `Invalid completion at property value`);
}
return Promise.resolve();
});
});
});
test('Skip when typing property values when there is a property in the next line (CSS)', () => {
const testContent = `
.foo {