Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (isStyleSheet(syntax)) {
let { prefixOptions, abbreviationWithoutPrefix } = splitVendorPrefix(abbreviation);
// If abbreviation is valid, then expand it and ensure the expanded value is not noise
if (isAbbreviationValid(syntax, abbreviation)) {
createExpandedAbbr(abbreviationWithoutPrefix);
}
// When abbr contains -, emmet uses it as a delimitor using the left to match propertyname and the right to match propertyvalue
// If there is css property that matches with abbr better, then that should win over emmet
if (abbreviationWithoutPrefix.indexOf('-') > 0 && cssData.properties.indexOf(abbreviationWithoutPrefix) > -1) {
return;
}
if (expandedAbbr) {
let prefixedExpandedText = applyVendorPrefixes(expandedText, prefixOptions, preferences);
expandedAbbr.textEdit = TextEdit.replace(abbreviationRange, escapeNonTabStopDollar(addFinalTabStop(prefixedExpandedText)));
expandedAbbr.documentation = replaceTabStopsWithCursors(prefixedExpandedText);
expandedAbbr.label = removeTabStops(expandedText);
expandedAbbr.filterText = abbreviation;
const stylesheetCustomSnippetsKeys = stylesheetCustomSnippetsKeyCache.has(syntax) ? stylesheetCustomSnippetsKeyCache.get(syntax) : stylesheetCustomSnippetsKeyCache.get('css');
completionItems = makeSnippetSuggestion(stylesheetCustomSnippetsKeys, abbreviation, abbreviation, abbreviationRange, expandOptions, 'Emmet Custom Snippet', false);
if (!completionItems.find(x => x.textEdit.newText === expandedAbbr.textEdit.newText)) {
// Fix for https://github.com/Microsoft/vscode/issues/28933#issuecomment-309236902
// When user types in propertyname, emmet uses it to match with snippet names, resulting in width -> widows or font-family -> font: family
// Filter out those cases here.
const abbrRegex = new RegExp('.*' + abbreviationWithoutPrefix.split('').map(x => x === '$' ? '\\$' : x).join('.*') + '.*', 'i');
if (/\d/.test(abbreviation) || abbrRegex.test(expandedAbbr.label)) {
completionItems.push(expandedAbbr);
}
languageFacts.cssDataManager.getProperties().forEach(function (p) {
var score = difference(propertyName, p.name);
if (score >= propertyName.length / 2 /*score_lim*/) {
candidates.push({ property: p.name, score: score });
}
});
// Sort in descending order.
candidates.sort(function (a, b) {
return b.score - a.score;
});
var maxActions = 3;
for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
var candidate = candidates_1[_i];
var propertyName_1 = candidate.property;
var title = localize('css.codeaction.rename', "Rename to '{0}'", propertyName_1);
var edit = TextEdit.replace(marker.range, propertyName_1);
var documentIdentifier = VersionedTextDocumentIdentifier.create(document.uri, document.version);
var workspaceEdit = { documentChanges: [TextDocumentEdit.create(documentIdentifier, [edit])] };
var codeAction = CodeAction.create(title, workspaceEdit, CodeActionKind.QuickFix);
codeAction.diagnostics = [marker];
result.push(codeAction);
if (--maxActions <= 0) {
return;
}
}
};
CSSCodeActions.prototype.appendFixesForMarker = function (document, stylesheet, marker, result) {
|| markupSnippetKeys.indexOf(abbreviation) > -1
|| commonlyUsedTags.indexOf(abbreviation) > -1) {
try {
expandedText = expand(abbreviation, expandOptions);
// Skip cases when abc -> abc: ; as this is noise
if (isStyleSheet(syntax) && expandedText === `${abbreviation}: \${1};`) {
expandedText = '';
}
} catch (e) {
}
}
if (expandedText) {
expandedAbbr = CompletionItem.create(abbreviation);
expandedAbbr.textEdit = TextEdit.replace(abbreviationRange, expandedText);
expandedAbbr.documentation = removeTabStops(expandedText);
expandedAbbr.insertTextFormat = InsertTextFormat.Snippet;
expandedAbbr.detail = 'Emmet Abbreviation';
if (filters.indexOf('bem') > -1) {
expandedAbbr.label = abbreviation + filterDelimitor + bemFilterSuffix;
}
if (isStyleSheet(syntax)) {
// See https://github.com/Microsoft/vscode/issues/28933#issuecomment-309236902
// Due to this we set filterText, sortText and label to expanded abbreviation
// - Label makes it clear to the user what their choice is
// - FilterText fixes the issue when user types in propertyname and emmet uses it to match with abbreviations
// - SortText will sort the choice in a way that is intutive to the user
expandedAbbr.filterText = expandedAbbr.documentation;
expandedAbbr.sortText = expandedAbbr.documentation;
expandedAbbr.label = expandedAbbr.documentation;
return CompletionList.create([expandedAbbr], true);
let k = offset - 1;
let characterStart = position.character;
while (k >= 0 && isLetterOrDigit(text, k)) {
k--;
characterStart--;
}
if (k >= 0 && text[k] === '&') {
let range = Range.create(Position.create(position.line, characterStart - 1), position);
for (let entity in entities) {
if (endsWith(entity, ';')) {
const label = '&' + entity;
result.items.push({
label,
kind: CompletionItemKind.Keyword,
documentation: localize('entity.propose', `Character entity representing '${entities[entity]}'`),
textEdit: TextEdit.replace(range, label),
insertTextFormat: InsertTextFormat.PlainText,
});
}
}
}
return result;
}
CSSCompletion.prototype.getPositionProposals = function (entry, existingNode, result) {
for (var position in languageFacts.positionKeywords) {
result.items.push({
label: position,
documentation: languageFacts.positionKeywords[position],
textEdit: TextEdit.replace(this.getCompletionRange(existingNode), position),
kind: CompletionItemKind.Value
});
}
return result;
};
CSSCompletion.prototype.getRepeatStyleProposals = function (entry, existingNode, result) {
let useSnippet = isSnippet && type !== 'boolean'
if (type !== 'boolean' && isSnippet) {
codeSnippet = codeSnippet + value
}
let command
if (useSnippet) {
command = {
title: 'Suggest',
command: 'editor.action.triggerSuggest'
}
}
result.items.push({
label: attribute,
documentation: info && info.desc ? info.desc.join('\n') : '',
kind: CompletionItemKind.Property,
textEdit: TextEdit.replace(range, codeSnippet),
insertTextFormat: useSnippet ? InsertTextFormat.Snippet : InsertTextFormat.PlainText,
command
})
})
return result
provider.collectExpressionValues(templateTag, value => {
result.items.push({
label: value,
kind: CompletionItemKind.Reference,
textEdit: TextEdit.replace(range, value + (text[offset] === '}' ? '' : '}')),
insertTextFormat: InsertTextFormat.PlainText,
});
});
});
CSSCompletion.prototype.getVariableProposals = function (existingNode, result) {
var symbols = this.getSymbolContext().findSymbolsAtOffset(this.offset, nodes.ReferenceType.Variable);
for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
var symbol = symbols_1[_i];
var insertText = strings.startsWith(symbol.name, '--') ? "var(" + symbol.name + ")" : symbol.name;
var suggest = {
label: symbol.name,
documentation: symbol.value ? strings.getLimitedString(symbol.value) : symbol.value,
textEdit: TextEdit.replace(this.getCompletionRange(existingNode), insertText),
kind: CompletionItemKind.Variable,
sortText: 'z'
};
if (symbol.node.type === nodes.NodeType.FunctionParameter) {
var mixinNode = (symbol.node.getParent());
if (mixinNode.type === nodes.NodeType.MixinDeclaration) {
suggest.detail = localize('completion.argument', 'argument from \'{0}\'', mixinNode.getName());
}
}
result.items.push(suggest);
}
return result;
};
CSSCompletion.prototype.getVariableProposalsForCSSVarFunction = function (result) {
provider.collectTags((tag, info) => {
result.items.push({
label: '/' + tag,
kind: CompletionItemKind.Property,
documentation: info.documentation,
filterText: '/' + tag + closeTag,
textEdit: TextEdit.replace(range, '/' + tag + closeTag),
insertTextFormat: InsertTextFormat.PlainText
});
});
});
for (var _i = 0, _a = entry.values; _i < _a.length; _i++) {
var value = _a[_i];
if (languageFacts.supportedInMoreThanOneBrowser(value)) {
var insertString = value.name;
var insertTextFormat = void 0;
if (strings.endsWith(insertString, ')')) {
var from = insertString.lastIndexOf('(');
if (from !== -1) {
insertString = insertString.substr(0, from) + '($1)';
insertTextFormat = SnippetFormat;
}
}
var item = {
label: value.name,
documentation: languageFacts.getEntryDescription(value),
textEdit: TextEdit.replace(this.getCompletionRange(existingNode), insertString),
kind: CompletionItemKind.Value,
insertTextFormat: insertTextFormat
};
result.items.push(item);
}
}
}
return result;
};
CSSCompletion.prototype.getCSSWideKeywordProposals = function (entry, existingNode, result) {