Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

fix broken highlighting for properties sharing selector names #234

Merged
merged 5 commits into from Oct 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions grammars/scss.cson
Expand Up @@ -26,6 +26,9 @@
{
'include': '#rules'
}
{
'include': '#selectors'
}
{
'include': '#property_list'
}
Expand Down Expand Up @@ -417,6 +420,9 @@
{
'include': '#rules'
}
{
'include': "#selectors"
}
]
}
]
Expand Down Expand Up @@ -973,7 +979,7 @@
'properties':
'patterns': [
{
'begin': '(?<![-a-z])(?=[-a-z])'
'begin': '(?<![-a-z])(?!--)(?=[-a-z])'
'end': '$|(?![-a-z])'
'name': 'meta.property-name.scss'
'patterns': [
Expand Down Expand Up @@ -1022,9 +1028,15 @@
{
'include': '#rules'
}
{
'include': '#selector_custom'
}
{
'include': '#properties'
}
{
'include': 'selectors'
}
{
'include': '$self'
}
Expand Down Expand Up @@ -1107,9 +1119,6 @@
{
'include': '#at_rule_media'
}
{
'include': '#selectors'
}
]
'selector_attribute':
'match': '''(?xi)
Expand Down
24 changes: 23 additions & 1 deletion spec/scss-spec.coffee
Expand Up @@ -369,7 +369,7 @@ describe 'SCSS grammar', ->
expect(tokens[32]).toEqual value: ')', scopes: ['source.css.scss', 'meta.property-list.scss', 'meta.property-value.scss', 'punctuation.definition.end.bracket.round.scss']

describe 'property names with a prefix that matches an element name', ->
it 'does not confuse them with properties', ->
it 'does not confuse them with selectors', ->
tokens = grammar.tokenizeLines '''
text {
text-align: center;
Expand All @@ -396,6 +396,28 @@ describe 'SCSS grammar', ->
expect(tokens[1][3]).toEqual value: ' ', scopes: ['source.css.scss', 'meta.property-list.scss']
expect(tokens[1][4]).toEqual value: 'fixed', scopes: ['source.css.scss', 'meta.property-list.scss', 'meta.property-value.scss', 'support.constant.property-value.css']

describe 'property names that match element names', ->
it 'does not confuse them with selectors', ->
tokens = grammar.tokenizeLines '''
content {
content: 'foo';
}
'''

expect(tokens[0][0]).toEqual value: 'content', scopes: ['source.css.scss', 'entity.name.tag.css']
expect(tokens[0][1]).toEqual value: ' ', scopes: ['source.css.scss']
expect(tokens[0][2]).toEqual value: '{', scopes: ['source.css.scss', 'meta.property-list.scss', 'punctuation.section.property-list.begin.bracket.curly.scss']
expect(tokens[1][0]).toEqual value: ' ', scopes: ['source.css.scss', 'meta.property-list.scss']
expect(tokens[1][1]).toEqual value: 'content', scopes: ['source.css.scss', 'meta.property-list.scss', 'meta.property-name.scss', 'support.type.property-name.css']
expect(tokens[1][2]).toEqual value: ':', scopes: ['source.css.scss', 'meta.property-list.scss', 'punctuation.separator.key-value.scss']
expect(tokens[1][3]).toEqual value: ' ', scopes: ['source.css.scss', 'meta.property-list.scss']
expect(tokens[1][4]).toEqual value: '\'', scopes: ['source.css.scss', 'meta.property-list.scss', 'meta.property-value.scss', 'string.quoted.single.scss', 'punctuation.definition.string.begin.scss']
expect(tokens[1][5]).toEqual value: 'foo', scopes: ['source.css.scss', 'meta.property-list.scss', 'meta.property-value.scss', 'string.quoted.single.scss']
expect(tokens[1][6]).toEqual value: '\'', scopes: ['source.css.scss', 'meta.property-list.scss', 'meta.property-value.scss', 'string.quoted.single.scss', 'punctuation.definition.string.end.scss']
expect(tokens[1][7]).toEqual value: ';', scopes: ['source.css.scss', 'meta.property-list.scss', 'punctuation.terminator.rule.scss']
expect(tokens[1][7]).toEqual value: ';', scopes: ['source.css.scss', 'meta.property-list.scss', 'punctuation.terminator.rule.scss']
expect(tokens[2][0]).toEqual value: '}', scopes: ['source.css.scss', 'meta.property-list.scss', 'punctuation.section.property-list.end.bracket.curly.scss']

describe 'vendor properties', ->
it 'tokenizes the browser prefix', ->
{tokens} = grammar.tokenizeLine 'body { -webkit-box-shadow: none; }'
Expand Down