tailwind-ctp-intellisense @master -
refs -
log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Fix `theme` helper handling when specifying default value (#747)
* Fix `theme` helper handling when specifying default value
* Tidy
Signature
-----BEGIN PGP SIGNATURE-----
wsBcBAABCAAQBQJkIex1CRBK7hj4Ov3rIwAAno0IABuGffWsfDRngiL19MgekI33
PnLvjXGtO/FWqGiHEc+TqfHKJVtc17m5tYgSnpk13zIX1RsBBRjJ+r/ebaKZqxdB
5U1QFi9Dr9l7PQHSSM2oQmd8MMJXLpoxcppeC8x5UEfFqx4PnNaF7s8nRk9VTyJ8
thH9UdesUw7ha+G5WomrmDSunUYodBrDDmSyh1TXe7+Z3yzJ/5KBWxOX95uum6WD
z06a79VdDWIk672CMFEsnEWIcfy9CPgaKZjpe0AuuSljbPYR/ByQMWXnoGNPRRpx
qrXX/zu3thbZ6I0b9ghQoB50QvDAsoIlHNbS+H1zouTpmsbrgXwYOkpsiJ4DsCs=
=7yPq
-----END PGP SIGNATURE-----
diff --git a/packages/tailwindcss-language-service/src/util/find.ts b/packages/tailwindcss-language-service/src/util/find.ts
index f9ffd20b20d329105861972a4916ba75d776a324..57141d571be08976ed72908ca317b9f45e77b193 100644
--- a/packages/tailwindcss-language-service/src/util/find.ts
+++ b/packages/tailwindcss-language-service/src/util/find.ts
@@ -348,6 +348,22 @@ .map(({ range }) => findHelperFunctionsInRange(doc, range))
)
}
+function getFirstCommaIndex(str: string): number | null {
+ let quoteChar: string | undefined
+ for (let i = 0; i < str.length; i++) {
+ let char = str[i]
+ if (char === ',' && !quoteChar) {
+ return i
+ }
+ if (!quoteChar && (char === '"' || char === "'")) {
+ quoteChar = char
+ } else if (char === quoteChar) {
+ quoteChar = undefined
+ }
+ }
+ return null
+}
+
export function findHelperFunctionsInRange(
doc: TextDocument,
range?: Range
@@ -360,7 +376,12 @@ )
return matches.map((match) => {
let quotesBefore = ''
- let path = match.groups.path.replace(/['"]+$/, '').replace(/^['"]+/, (m) => {
+ let path = match.groups.path
+ let commaIndex = getFirstCommaIndex(path)
+ if (commaIndex !== null) {
+ path = path.slice(0, commaIndex).trimEnd()
+ }
+ path = path.replace(/['"]+$/, '').replace(/^['"]+/, (m) => {
quotesBefore = m
return ''
})