Skip to content

Make class search range larger #1192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 12, 2025
Merged

Conversation

thecrypticace
Copy link
Contributor

After doing an admittedly quite small amount of benchmarking it seems that expanding the search range does have a perf impact but it's not so much of one that we shouldn't increase it. Though this very likely depends on the regex in use.

I've done a few major things in this PR:

  • Searching for class lists when hovering now starts at the beginning of the document. This important for users who are using things like cva (the same reason it was expanded for completions in Expand classRegex search range #840)
  • The search range for completions inside a class attribute have been expanded to 15k characters. This is useful if you're using a really large cva definition in one class list.
  • Ditto for searching for custom regexes which is useful when using CVA with separate variables in a JSX/TSX document.

Fixes #1032
Fixes #984

This is a mostly a stop-gap measure until I can land a better system for "parsing" documents that aims to make most class detection trivial and quite fast.

Custom regexes won't necessarily be able to take advantage of that but if I can get some perf wins elsewhere I might be able to expand the search range even further. Ideally I'd figure out a way to run regexes in a worker thread and allow them to be "cancelled" when they take too long but that is a fairly major-ish undertaking.

We already do this for completions and this is required for larger documents with custom regexes so we might as well do it here too
@thecrypticace thecrypticace marked this pull request as ready for review February 11, 2025 21:46
@thecrypticace thecrypticace merged commit b32b3b0 into main Feb 12, 2025
@thecrypticace thecrypticace deleted the feat/expanded-search-range branch February 12, 2025 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Intellisense stop working with CVA with a lot of variants (searchRange too small) classRegex in a complex js object
2 participants