Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes vscode #65464 #46

Merged
merged 1 commit into from
Feb 9, 2021
Merged

Conversation

jeanp413
Copy link
Contributor

@jeanp413 jeanp413 commented Feb 8, 2021

@@ -495,7 +495,11 @@ export function isAbbreviationValid(syntax: string, abbreviation: string): boole
return false;
}
if (abbreviation.includes('#')) {
return hexColorRegex.test(abbreviation) || propertyHexColorRegex.test(abbreviation);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether propertyHexColorRegex should still show up. For example, bgc:#333 is valid (and expands to background-color: #333;).

Copy link
Contributor Author

@jeanp413 jeanp413 Feb 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are tests for that case and they still pass

const testCases: [string, string][] = [
['#1', '#111'],
['#ab', '#ababab'],
['#abc', '#abc'],
['c:#1', 'color: #111;'],
['c:#1a', 'color: #1a1a1a;'],
['bgc:1', 'background-color: 1px;'],
['c:#0.1', 'color: rgba(0, 0, 0, 0.1);']
];

if (abbreviation.startsWith('#')) {
return hexColorRegex.test(abbreviation);
} else if (commonlyUsedTags.includes(abbreviation.substring(0, abbreviation.indexOf('#')))) {
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what this case is for, considering we're in a if (isStyleSheet(syntax)) block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rzhao271 The whole if (abbreviation.includes('#')) block was added as a fix for this microsoft/vscode#56082 where emmet completions would show for id selectors and that's not desired. propertyHexColorRegex regex is too restrictive causing expressions like bd1#s not being expanded so the fix is to not show completions only for id selectors of the form <element>#<id>

@rzhao271
Copy link
Contributor

rzhao271 commented Feb 9, 2021

Thanks again! Merging

@rzhao271 rzhao271 merged commit 73a2350 into microsoft:main Feb 9, 2021
@jeanp413 jeanp413 deleted the fix-vscode#65464 branch February 9, 2021 22:43
@rzhao271 rzhao271 added this to the February 2021 milestone Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emmet CSS # character
2 participants