in src/emmetHelper.ts [522:584]
function isExpandedTextNoise(syntax: string, abbreviation: string, expandedText: string, options: Partial<Options> | undefined): boolean {
// Unresolved css abbreviations get expanded to a blank property value
// Eg: abc -> abc: ; or abc:d -> abc: d; which is noise if it gets suggested for every word typed
if (isStyleSheet(syntax) && options) {
const between = options['stylesheet.between'] ?? ': ';
const after = options['stylesheet.after'] ?? ';';
// Remove overlapping between `abbreviation` and `between`, if any
let endPrefixIndex = abbreviation.indexOf(between[0], Math.max(abbreviation.length - between.length, 0));
endPrefixIndex = endPrefixIndex >= 0 ? endPrefixIndex : abbreviation.length;
const abbr = abbreviation.substring(0, endPrefixIndex);
return expandedText === `${abbr}${between}\${0}${after}` ||
expandedText.replace(/\s/g, '') === abbreviation.replace(/\s/g, '') + after;
}
// we don't want common html tags suggested for xml
if (syntax === 'xml' &&
commonlyUsedTags.some(tag => tag.startsWith(abbreviation.toLowerCase()))) {
return true;
}
if (commonlyUsedTags.includes(abbreviation.toLowerCase()) ||
markupSnippetKeys.includes(abbreviation)) {
return false;
}
// Custom tags can have - or :
if (/[-,:]/.test(abbreviation) && !/--|::/.test(abbreviation) &&
!abbreviation.endsWith(':')) {
return false;
}
// Its common for users to type some text and end it with period, this should not be treated as an abbreviation
// Else it becomes noise.
// When user just types '.', return the expansion
// Otherwise emmet loses change to participate later
// For example in `.foo`. See https://github.com/Microsoft/vscode/issues/66013
if (abbreviation === '.') {
return false;
}
const dotMatches = abbreviation.match(/^([a-z,A-Z,\d]*)\.$/);
if (dotMatches) {
// Valid html tags such as `div.`
if (dotMatches[1] && htmlData.tags.includes(dotMatches[1])) {
return false;
}
return true;
}
// Fix for https://github.com/microsoft/vscode/issues/89746
// PascalCase tags are common in jsx code, which should not be treated as noise.
// Eg: MyAwesomComponent -> <MyAwesomComponent></MyAwesomComponent>
if (syntax === 'jsx' && /^([A-Z][A-Za-z0-9]*)+$/.test(abbreviation)) {
return false;
}
// Unresolved html abbreviations get expanded as if it were a tag
// Eg: abc -> <abc></abc> which is noise if it gets suggested for every word typed
return (expandedText.toLowerCase() === `<${abbreviation.toLowerCase()}>\${1}</${abbreviation.toLowerCase()}>`);
}