-
Notifications
You must be signed in to change notification settings - Fork 33
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
Conversation
@@ -495,7 +495,11 @@ export function isAbbreviationValid(syntax: string, abbreviation: string): boole | |||
return false; | |||
} | |||
if (abbreviation.includes('#')) { | |||
return hexColorRegex.test(abbreviation) || propertyHexColorRegex.test(abbreviation); |
There was a problem hiding this comment.
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;
).
There was a problem hiding this comment.
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
vscode-emmet-helper/src/test/emmetHelper.test.ts
Lines 713 to 721 in 4fa2577
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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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>
Thanks again! Merging |
Fixes microsoft/vscode#65464