Suppress filter updates for unchanged semantic search meaning #3435
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
If you manually type a search for
is:compatible
(or various other similar searches likenot:compatible
,is:cached
, etc.) rather than clicking the check/X buttons in the dropdown, the UI responds very sluggishly on Windows.Notably, this doesn't happen for something like
dep:kopernicus
or searching for fragments of a name, where each keystroke is pretty snappy.Cause
A search for
is:compatibl
(note the missinge
at the end) or any shorter substring is the same as an empty search, because we parse theis:
prefix first and check whether the suffix matches any of our known strings, and if it doesn't, we just discard that part of the search. However, the UI still treats this as if it was a new search that needs a refresh at each keystroke, so we callManageMods.UpdateFilters
and re-generate the list. Since no mods are filtered out, this takes a while, especially when it happens repeatedly while you are typing.For
dep:kopernicus
:d
,de
, anddep:k
each filters the list significantly, so the refresh is quick enough to keep up with user keystrokes.Linux and Mac appear to be unaffected because they use a timer to delay searches.
Changes
Now we only update the filters if the new searches have a different semantic meaning than the old searches. So while you are typing
is:compatibl
, each intermediate search is determined to be equivalent to the default empty search, so nothing happens until you add the finale
, at which point we show the list of compatible mods, which is quick because it's a shorter list.To do this,
ModSearch.Equals
is now defined to return whether two searches have the same meaning, andModList.SearchesEqual
is a short wrapper aroundSequenceEqual
to handle nulls. We only trigger a full refresh ifSearchesEqual
returns false.Fixes #3402.