Disallow parenthesis in non-pseudo CSS selectors

* lisp/textmodes/css-mode.el (css--font-lock-keywords): Disallow
parenthesis in selectors except for in the function notation that
might appear right after a pseudo-class.
* test/indent/scss-mode.scss: Add a test for it.
This commit is contained in:
Simen Heggestøyl 2016-01-14 19:24:03 +01:00
parent d5f1db83ec
commit dadb841a06
2 changed files with 15 additions and 5 deletions

View file

@ -257,13 +257,13 @@
(if (not sassy)
;; We don't allow / as first char, so as not to
;; take a comment as the beginning of a selector.
"[^@/:{} \t\n][^:{}]+"
"[^@/:{}() \t\n][^:{}()]+"
;; Same as for non-sassy except we do want to allow { and }
;; chars in selectors in the case of #{$foo}
;; variable interpolation!
(concat "\\(?:" scss--hash-re
"\\|[^@/:{} \t\n#]\\)"
"[^:{}#]*\\(?:" scss--hash-re "[^:{}#]*\\)*"))
"\\|[^@/:{}() \t\n#]\\)"
"[^:{}()#]*\\(?:" scss--hash-re "[^:{}()#]*\\)*"))
;; Even though pseudo-elements should be prefixed by ::, a
;; single colon is accepted for backward compatibility.
"\\(?:\\(:" (regexp-opt (append css-pseudo-class-ids
@ -271,8 +271,8 @@
"\\|\\::" (regexp-opt css-pseudo-element-ids t) "\\)"
"\\(?:([^)]+)\\)?"
(if (not sassy)
"[^:{}\n]*"
(concat "[^:{}\n#]*\\(?:" scss--hash-re "[^:{}\n#]*\\)*"))
"[^:{}()\n]*"
(concat "[^:{}()\n#]*\\(?:" scss--hash-re "[^:{}()\n#]*\\)*"))
"\\)*"
"\\)\\(?:\n[ \t]*\\)*{")
(1 'css-selector keep))

View file

@ -55,3 +55,13 @@ article[role="main"] {
}
.box { @include border-radius(10px); }
// bug:21230
$list: (
('a', #000000, #fff)
('b', #000000, #fff)
('c', #000000, #fff)
('d', #000000, #fff)
('e', #000000, #fff)
('f', #000000, #fff)
);