From c08bb7a84728bae4edbee3ba47aa1cd17e6da53b Mon Sep 17 00:00:00 2001 From: dweep Date: Sun, 5 Jul 2026 12:12:05 +0530 Subject: [PATCH] SCSS: Support parameterized pseudo-classes in selectors Fixes #3740. Selectors like `:foo()` were not being highlighted because the selector pattern excluded all parentheses. This adds a constrained alternative that only allows balanced parens when they directly follow a pseudo-class (`:name(...)` or `::name(...)`), which fixes the reported case without regressing the @mixin/@include argument-list case Golmote flagged in the original workaround. --- src/languages/scss.js | 2 +- tests/languages/scss/selector_feature.test | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/languages/scss.js b/src/languages/scss.js index e23fe29950..6277f7db5c 100644 --- a/src/languages/scss.js +++ b/src/languages/scss.js @@ -29,7 +29,7 @@ export default { 'selector': { // Initial look-ahead is used to prevent matching of blank selectors pattern: - /(?=\S)[^@;{}()]?(?:[^@;{}()\s]|\s+(?!\s)|#\{\$[-\w]+\})+(?=\s*\{(?:\}|\s|[^}][^:{}]*[:{][^}]))/, + /(?=\S)[^@;{}()]?(?:[^@;{}()\s]|\s+(?!\s)|#\{\$[-\w]+\}|:{1,2}[-\w]+\((?:[^()]|\([^()]*\))*\))+(?=\s*\{(?:\}|\s|[^}][^:{}]*[:{][^}]))/, inside: { 'parent': { pattern: /&/, diff --git a/tests/languages/scss/selector_feature.test b/tests/languages/scss/selector_feature.test index cb305dfbd6..32cd21cbd3 100644 --- a/tests/languages/scss/selector_feature.test +++ b/tests/languages/scss/selector_feature.test @@ -5,9 +5,8 @@ p, div {} &-sidebar {} #context a%extreme {} #{$selector}:before {} - +foo :foo() bar {} ---------------------------------------------------- - [ ["selector", ["a "]], ["punctuation", "{"], ["punctuation", "}"], ["selector", ["p, div "]], ["punctuation", "{"], ["punctuation", "}"], @@ -15,9 +14,8 @@ p, div {} ["selector", [["parent", "&"], ":hover "]], ["punctuation", "{"], ["punctuation", "}"], ["selector", [["parent", "&"], "-sidebar "]], ["punctuation", "{"], ["punctuation", "}"], ["selector", ["#context a", ["placeholder", "%extreme"]]], ["punctuation", "{"], ["punctuation", "}"], - ["selector", [["variable", "#{$selector}"], ":before "]], ["punctuation", "{"], ["punctuation", "}"] + ["selector", [["variable", "#{$selector}"], ":before "]], ["punctuation", "{"], ["punctuation", "}"], + ["selector", ["foo :foo() bar "]], ["punctuation", "{"], ["punctuation", "}"] ] - ---------------------------------------------------- - -Checks for selectors. \ No newline at end of file +Checks for selectors.