Skip to content

Commit d3672ba

Browse files
committed
Merge PR Allow escaped characters in css selectors zignd#289
2 parents f6bdfa0 + 247b72f commit d3672ba

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Diff for: src/extension.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -141,29 +141,29 @@ const registerHTMLProviders = (disposables: Disposable[]) =>
141141
workspace.getConfiguration()
142142
?.get<string[]>(Configuration.HTMLLanguages)
143143
?.forEach((extension) => {
144-
disposables.push(registerCompletionProvider(extension, /class=["|']([\w- ]*$)/));
144+
disposables.push(registerCompletionProvider(extension, /class=["|']([\w-@:\/ ]*$)/));
145145
});
146146

147-
const registerCSSProviders = (disposables: Disposable[]) =>
147+
const registerCSSProviders = (disposables: Disposable[]) =>
148148
workspace.getConfiguration()
149149
.get<string[]>(Configuration.CSSLanguages)
150150
?.forEach((extension) => {
151151
// The @apply rule was a CSS proposal which has since been abandoned,
152152
// check the proposal for more info: http://tabatkins.github.io/specs/css-apply-rule/
153153
// Its support should probably be removed
154-
disposables.push(registerCompletionProvider(extension, /@apply ([.\w- ]*$)/, "."));
154+
disposables.push(registerCompletionProvider(extension, /@apply ([.\w-@:\/ ]*$)/, "."));
155155
});
156156

157157
const registerJavaScriptProviders = (disposables: Disposable[]) =>
158158
workspace.getConfiguration()
159159
.get<string[]>(Configuration.JavaScriptLanguages)
160160
?.forEach((extension) => {
161-
disposables.push(registerCompletionProvider(extension, /className=["|']([\w- ]*$)/));
162-
disposables.push(registerCompletionProvider(extension, /class=["|']([\w- ]*$)/));
161+
disposables.push(registerCompletionProvider(extension, /className=["|']([\w-@:\/ ]*$)/));
162+
disposables.push(registerCompletionProvider(extension, /class=["|']([\w-@:\/ ]*$)/));
163163
});
164164

165165
function registerEmmetProviders(disposables: Disposable[]) {
166-
const emmetRegex = /(?=\.)([\w-. ]*$)/;
166+
const emmetRegex = /(?=\.)([\w-@:\/. ]*$)/;
167167

168168
const registerProviders = (modes: string[]) => {
169169
modes.forEach((language) => {

Diff for: src/parse-engines/common/css-class-extractor.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default class CssClassExtractor {
66
* @description Extracts class names from CSS AST
77
*/
88
public static extract(ast: css.Stylesheet): CssClassDefinition[] {
9-
const classNameRegex = /[.]([\w-]+)/g;
9+
const classNameRegex = /[.](([\w-]|\\[@:/])+)/g;
1010

1111
const definitions: CssClassDefinition[] = [];
1212

@@ -15,7 +15,7 @@ export default class CssClassExtractor {
1515
rule.selectors?.forEach((selector: string) => {
1616
let item: RegExpExecArray | null = classNameRegex.exec(selector);
1717
while (item) {
18-
definitions.push(new CssClassDefinition(item[1]));
18+
definitions.push(new CssClassDefinition(item[1].replace("\\", "")));
1919
item = classNameRegex.exec(selector);
2020
}
2121
});
@@ -35,4 +35,4 @@ export default class CssClassExtractor {
3535
});
3636
return definitions;
3737
}
38-
}
38+
}

0 commit comments

Comments
 (0)