Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions grammars/css.cson
Original file line number Diff line number Diff line change
Expand Up @@ -674,11 +674,20 @@
'match': '(?i)(?<![\\w-])currentColor(?![\\w-])'
'name': 'support.constant.color.current.css'
}
{
# CSS4 color names https://drafts.csswg.org/css-color-4/#css-system-colors
'match': '''(?xi) (?<![\\w-])
(accentcolor|accentcolortext|activetext|buttonborder|buttonface|buttontext|canvas|canvastext|field|fieldtext
|graytext|highlight|highlighttext|linktext|mark|marktext|selecteditem|selecteditemtext|visitedtext)
(?![\\w-])
'''
'name': 'support.constant.color.system.css'
}
{
# These colours are deprecated in CSS3: http://www.w3.org/TR/css3-color/#css2-system
'match': '''(?xi) (?<![\\w-])
(ActiveBorder|ActiveCaption|AppWorkspace|Background|ButtonFace|ButtonHighlight|ButtonShadow
|ButtonText|CaptionText|GrayText|Highlight|HighlightText|InactiveBorder|InactiveCaption
(ActiveBorder|ActiveCaption|AppWorkspace|Background|ButtonHighlight|ButtonShadow
|CaptionText|InactiveBorder|InactiveCaption
Comment on lines +689 to +690
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Overlapping values with system colors have been moved, these are no longer deprecated.

|InactiveCaptionText|InfoBackground|InfoText|Menu|MenuText|Scrollbar|ThreeDDarkShadow
|ThreeDFace|ThreeDHighlight|ThreeDLightShadow|ThreeDShadow|Window|WindowFrame|WindowText)
(?![\\w-])
Expand Down
28 changes: 28 additions & 0 deletions spec/css-spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2486,6 +2486,34 @@ describe('CSS grammar', function () {
assert.deepStrictEqual(tokens[8], { scopes: ['source.css', 'meta.property-list.css', 'meta.property-value.css', 'support.constant.color.w3c-extended-color-name.css'], value: 'snow' });
});

it('tokenizes system color keywords', function () {
var tokens;
tokens = testGrammar.tokenizeLine('a { color: AccentColor; }').tokens;
assert.deepStrictEqual(tokens[7], {
value: 'AccentColor',
scopes: ['source.css', 'meta.property-list.css', 'meta.property-value.css', 'support.constant.color.system.css']
});
});

it('tokenizes deprecated system color keywords', function () {
var tokens;
tokens = testGrammar.tokenizeLine('a { color: background; }').tokens;
assert.deepStrictEqual(tokens[7], {
value: 'background',
scopes: ['source.css', 'meta.property-list.css', 'meta.property-value.css', 'invalid.deprecated.color.system.css']
});
});

// https://github.com/microsoft/vscode-css/issues/21
it.skip('does not confuse property names for deprecated color keywords', function () {
var tokens;
tokens = testGrammar.tokenizeLine('a { transition-property: background; }').tokens;
assert.deepStrictEqual(tokens[7], {
value: 'background',
scopes: ['source.css', 'meta.property-list.css', 'meta.property-value.css', 'support.constant.property-value.css']
});
});

it('tokenises RGBA values in hex notation', function () {
var tokens;
tokens = testGrammar.tokenizeLine('p{ color: #f030; }').tokens;
Expand Down