-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make class search range larger (#1192)
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 #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.
- Loading branch information
1 parent
c2660e4
commit b32b3b0
Showing
4 changed files
with
11 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** | ||
* The maximum bounds around the cursor when searching for class names | ||
*/ | ||
export const SEARCH_RANGE = 15_000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters