Skip to content

Commit 9915121

Browse files
committed
Update #selector rules and include it in the rule-list-innards patterns
1 parent 10db2a0 commit 9915121

File tree

1 file changed

+66
-10
lines changed

1 file changed

+66
-10
lines changed

src/vscode-css/grammars/css.cson

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,9 @@
17491749
'''
17501750
'name': 'variable.css'
17511751
}
1752+
{
1753+
'include': '#selector'
1754+
}
17521755
{
17531756
'begin': '(?<![-a-zA-Z])(?=[-a-zA-Z])'
17541757
'end': '$|(?![-a-zA-Z])'
@@ -1784,20 +1787,73 @@
17841787
}
17851788
]
17861789
'selector':
1787-
'begin': '''(?x)
1790+
'begin': '''(?xi)
1791+
# Match must be preceded by one of the following:
1792+
(?<=
1793+
^ # Start of line
1794+
| (^|[^\\:])\\s # Whitespace, after the start of a line or any character except a colon (which denotes a property)
1795+
| ; # Semicolon (condensed property list syntax)
1796+
| [{}] # Opening or closing brace (condensed property list syntax)
1797+
| \\*/ # Comment end
1798+
| \\\\(?:[0-9a-fA-F]{1,6}|.) # Escape sequence
1799+
)
1800+
1801+
# Match may contain any of the following:
1802+
(?=
1803+
(?:
1804+
# Match must start with one of the following:
1805+
& # Nesting selector
1806+
| \\* # Universal selector
1807+
| [>~+] # Selector combinator
1808+
| \\| # Selector namespace separator
1809+
| \\[ # Attribute selector opening bracket
1810+
| [a-zA-Z] # Letter
1811+
| [^\\x00-\\x7F] # Non-ASCII symbols
1812+
| \\\\(?:[0-9a-fA-F]{1,6}|.) # Escape sequence
1813+
1814+
# Or one of the following symbols, followed by a word character, hyphen, or escape sequence:
1815+
| (?:
1816+
\\. # Class selector
1817+
| \\# # ID selector
1818+
)
1819+
(?:
1820+
[\\w-] # Word character or hyphen
1821+
| \\\\(?: # Escape sequence
1822+
[0-9a-fA-F]{1,6}
1823+
| .
1824+
)
1825+
)
1826+
1827+
# Or one of the following symbols, followed a letter or hyphen:
1828+
| (?:
1829+
\\: # Pseudo-class
1830+
| \\:\\: # Pseudo-element
1831+
)
1832+
[a-zA-Z-] # Letter or hyphen
1833+
)
1834+
)
1835+
1836+
# Match must NOT contain any of the following:
1837+
(?!
1838+
[\\w-]*[\\:]+\\s # One or more colons immediately followed by a whitespace (denotes a property or invalid sequence)
1839+
| [^{]*; # Any characters and a semicolon before an opening bracket (denotes the end of a property)
1840+
| [^{]*} # A closing bracket before an opening bracket (denotes a property)
1841+
| [^\\:]+(\\:\\:):+ # More than two colons (invalid sequence)
1842+
)
1843+
'''
1844+
'end': '''(?x)
1845+
# Match must end with:
17881846
(?=
1789-
(?:\\|)? # Possible anonymous namespace prefix
1847+
\\s* # Optional whitespace and one of the following:
17901848
(?:
1791-
[-\\[:.*&\\#a-zA-Z_] # Valid selector character
1792-
|
1793-
[^\\x00-\\x7F] # Which can include non-ASCII symbols
1794-
|
1795-
\\\\ # Or an escape sequence
1796-
(?:[0-9a-fA-F]{1,6}|.)
1849+
\\/ # Comment
1850+
| @ # At-rule
1851+
| { # Opening property list brace
1852+
| \\) # Closing function brace (for passing test on `some-edgy-new-function(`)
1853+
| $ # End of line
17971854
)
17981855
)
1799-
'''
1800-
'end': '(?=\\s*[/@{)])'
1856+
'''
18011857
'name': 'meta.selector.css'
18021858
'patterns': [
18031859
{

0 commit comments

Comments
 (0)