Closed mfb-davidmay closed 5 months ago
Some additional information from my machine that might help.
Version: 1.85.1 (user setup)
Commit: 0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2
Date: 2023-12-13T09:49:37.021Z
Electron: 25.9.7
ElectronBuildId: 25551756
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.19045
Just following up with some notes from tinkering around with the regex container, I believe the issue lies with the amount of data captured with the container regex (?<=tv\\()[^]*?(?=}\\))
which is is a capture group of 3,558 characters.
When I change the capture group to something much smaller, and general (it's basically matching any, and every string in the file now) the extension is working as expected, and not timing out anymore. This change results in container capture groups of 200-400 characters.
Here's what I changed it to.
{
"tailwindCSS.experimental.classRegex": [
["([\"'`][^\"'`]*.*?[\"'`])", "[\"'`]([^\"'`]*).*?[\"'`]"]
]
}
Ideally, having the ability to specify (?<=tv\([^]*?)([\"'`][^\"'`]*.*?[\"'`])(?=[^]*?}\);?$)
which contains both a positive lookbehind, and positive lookahead to scope matches within the tv function would be the ultimate setup. But I think the regex library you're using doesn't support these regex features, or maybe I'm doing something wrong because intellisense is turned off with this configuration.
I experimented with the becke-ch--regex--s0-0-v1--base--pl--lib
using this regex and it returns matches with gm
flags so unsure what's going on.
I had the same issue. I was surprised considering its a Macbook pro 16" M3 Max with 64GB memory 🤦🏻
I had the same issue. I was surprised considering its a Macbook pro 16" M3 Max with 64GB memory 🤦🏻
Ha, not surprised tbh. There's a lot of code that gets executed with the container match regex.
"([\"'`][^\"'`]*.*?[\"'`])", "[\"'`]([^\"'`]*).*?[\"'`]"
while overly general in terms of what it matches in a file will at least stop turning your laptop into a portable heater.
The problem is with (?<=['\"])[\\w\\-\\s:\\[\\]\\.]*?(?=['\"])
. It matches a zero-length string at a specific position.
Here, a very simplified, non-escaped form: /(?<=')\w*?(?=')/
— this regex basically says match anything zero characters or more between single quotes but not the quotes themselves. Given the string let x = ''
it'll match the position between the quotes. And because it's zero length, the exec
call in becke-ch--regex--s0-0-v1--base--pl--lib
appears to never advance an internal pointer or something resulting in an infinite loop which ends up allocating more and more memory.
I have a fix for this but I'm not yet sure if it's the right fix. I need to do some more testing today.
Turns out my fix wasn't that good so I ended up rewriting things, discovered new JS APIs in the process, and rewrote things some more.
I have a little bit more testing to do but I think things are in a better spot for this now. Should have at least a fix in the pre-release version of the extension tomorrow.
Was hoping to get a pre-release out today but I've run into something odd — I think it's a v8 bug but I'm not 100% sure yet.
I just merged #897 which fixes this. It'll be available in the pre-release version of the extension. If you could give it a test and report back to me that would be 💯
I'm using pre-release version but I'm suffering from the same issue.
@dgknca can you open a separate issue with a reproduction that I can take a look at?
@dgknca can you open a separate issue with a reproduction that I can take a look at?
I was using this regex https://www.tailwind-variants.org/docs/getting-started#intellisense-setup-optional
{
"tailwindCSS.experimental.classRegex": [
["tv\\((([^()]*|\\([^()]*\\))*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"]
]
}
replaced it with:
["([\"'`][^\"'`]*.*?[\"'`])", "[\"'`]([^\"'`]*).*?[\"'`]"]
works fine now.
What version of VS Code are you using?
Version:
1.85.1 (user setup)
What version of Tailwind CSS IntelliSense are you using?
v0.10.4
also triedv0.11.36
What version of Tailwind CSS are you using?
^3.3.6
What package manager are you using?
yarn berry v3.7.0
What operating system are you using?
Windows 10
Tailwind config
VS Code settings
Reproduction URL
https://github.com/mfb-davidmay/tw-intellisense-timeout/blob/main/src/components/Button/index.tsx
Describe your issue
When attempting to load Intellisense for the aforementioned file, Visual Studio will consume large amounts of memory and CPU to the point that the Tailwind Extension runs out of memory.
I've pinpointed the issue to be an experimental regex that I've added which was recommended by the author of the
tailwind-variants
library. The regex shown here is my attempt to improve the one suggested to simplify the matching.I believe the memory exception might be because there's too many classes matched within the container? but unsure as the logging of the extension isn't telling me much.
Removing the classRegex returns the extension back to normal, and I can use it with standard out of the box support. Just wanting some help to understand what I can do to enable support for the
tv(...)
functions in my components.Here's the extension output.