Skip to content

Commit 6e04329

Browse files
committed
Use d flag from RegExp
This means we no longer need an external package for this too!
1 parent 330c412 commit 6e04329

File tree

1 file changed

+6
-7
lines changed
  • packages/tailwindcss-language-service/src/util

1 file changed

+6
-7
lines changed

packages/tailwindcss-language-service/src/util/classes.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import Regex from 'becke-ch--regex--s0-0-v1--base--pl--lib'
21

32
export type ClassRegexEntry = string | [string] | [string, string]
4-
export type ClassRegex = [container: Regex, cls?: Regex]
3+
export type ClassRegex = [container: RegExp, cls?: RegExp]
54
export interface ClassMatch {
65
classList: string
76
}
@@ -16,7 +15,7 @@ export function customClassesIn(
1615
? pattern
1716
: [pattern]
1817

19-
let regexes = normalized.map((pattern) => new Regex(pattern, 'g'))
18+
let regexes = normalized.map((pattern) => new RegExp(pattern, 'gd'))
2019

2120
let match = firstMatchIn(str, cursor, regexes as ClassRegex)
2221

@@ -33,10 +32,10 @@ function firstMatchIn(
3332
cursor: number,
3433
[containerRegex, classRegex]: ClassRegex,
3534
): ClassMatch | null {
36-
let containerMatch: ReturnType<Regex['exec']>
35+
let containerMatch: ReturnType<RegExp['exec']>
3736

3837
while ((containerMatch = containerRegex.exec(str)) !== null) {
39-
const matchStart = containerMatch.index[1]
38+
const matchStart = containerMatch.indices[1][0]
4039
const matchEnd = matchStart + containerMatch[1].length
4140

4241
// Cursor is outside of the match
@@ -51,10 +50,10 @@ function firstMatchIn(
5150
}
5251

5352
// Handle class matches inside the "container"
54-
let classMatch: ReturnType<Regex['exec']>
53+
let classMatch: ReturnType<RegExp['exec']>
5554

5655
while ((classMatch = classRegex.exec(containerMatch[1])) !== null) {
57-
const classMatchStart = matchStart + classMatch.index[1]
56+
const classMatchStart = matchStart + classMatch.indices[1][0]
5857
const classMatchEnd = classMatchStart + classMatch[1].length
5958

6059
// Cursor is outside of the match

0 commit comments

Comments
 (0)