Skip to content

Commit 4025d16

Browse files
fix: regex
1 parent 1cd7dee commit 4025d16

3 files changed

Lines changed: 3 additions & 7 deletions

File tree

package-lock.json

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/completions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ export async function registerCompletions(ctx: ExtensionContext, core: Core): Pr
9292
const colors: ColorInformation[] = [];
9393
for (const line of Array.from(Array(document.lineCount).keys())) {
9494
const text = document.lineAt(line).text;
95-
if (text.match(/[class|className|dark|light|active|after|before|checked|disabled|focus|hover|tw]=["|']([.\w-+@: ]*)/)) {
96-
const matched = text.match(/(?<=[class|className|dark|light|active|after|before|checked|disabled|focus|hover|tw]=["|'])[^"']*/);
95+
if (text.match(/(class|className|dark|light|active|after|before|checked|disabled|focus|hover|tw)=["|']([.\w-+@: ]*)/)) {
96+
const matched = text.match(/(?<=(class|className|dark|light|active|after|before|checked|disabled|focus|hover|tw)=["|'])[^"']*/);
9797
if (matched && matched.index) {
9898
const offset = matched.index;
9999
const elements = new ClassParser(matched[0]).parse(false);

src/utils/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export class HTMLParser {
66
parseClasses(): { start: number; end: number; result: string }[] {
77
// Match all class properties
88
if (!this.html) return [];
9-
const classRegex = /[class|className|dark|light|active|after|before|checked|disabled|focus|hover|tw]\s*=\s*(["'])(?:(?=(\\?))\2.)*?\1/;
9+
const classRegex = /(class|className|dark|light|active|after|before|checked|disabled|focus|hover|tw)\s*=\s*(["'])(?:(?=(\\?))\2.)*?\1/;
1010
const quoteRegex = /["']/;
1111
const classNames = [];
1212
let _indexStart = 0;

0 commit comments

Comments
 (0)