Skip to content

Commit c2c5d9b

Browse files
committed
Bail when a replacement references the variable its replacing
This isn’t “great” but it’s a good stop gap measure for now
1 parent 14f8f82 commit c2c5d9b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/tailwindcss-language-service/src/util/rewriting/replacements.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ export function replaceCssVars(
7676
})
7777

7878
if (replacement !== null) {
79+
// If we're replacing this variable with a reference back it *itself*
80+
// we should skip over it
81+
if (replacement.includes(`var(${varName})`) || replacement.includes(`var(${varName},`)) {
82+
break
83+
}
84+
7985
str = str.slice(0, i) + replacement + str.slice(j + 1)
8086
}
8187

0 commit comments

Comments
 (0)