mirror of
https://github.com/ppy/osu.git
synced 2024-11-14 15:17:27 +08:00
Trim full phrase filters in a more precise manner
This commit is contained in:
parent
aba380b001
commit
bf99fc61b8
@ -76,8 +76,8 @@ namespace osu.Game.Tests.NonVisual.Filtering
|
||||
Assert.AreEqual("\"!", filterCriteria.SearchText);
|
||||
Assert.AreEqual(1, filterCriteria.SearchTerms.Length);
|
||||
|
||||
Assert.That(filterCriteria.SearchTerms[0].SearchTerm, Is.EqualTo("\"!"));
|
||||
Assert.That(filterCriteria.SearchTerms[0].MatchMode, Is.EqualTo(FilterCriteria.MatchMode.Substring));
|
||||
Assert.That(filterCriteria.SearchTerms[0].SearchTerm, Is.EqualTo("!"));
|
||||
Assert.That(filterCriteria.SearchTerms[0].MatchMode, Is.EqualTo(FilterCriteria.MatchMode.IsolatedPhrase));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -174,15 +174,19 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
searchTerm = value;
|
||||
|
||||
if (searchTerm.EndsWith("\"!", StringComparison.Ordinal))
|
||||
if (searchTerm.StartsWith('\"'))
|
||||
{
|
||||
searchTerm = searchTerm.Trim('!', '\"');
|
||||
MatchMode = MatchMode.FullPhrase;
|
||||
}
|
||||
else if (searchTerm.StartsWith('\"'))
|
||||
{
|
||||
searchTerm = searchTerm.Trim('\"');
|
||||
MatchMode = MatchMode.IsolatedPhrase;
|
||||
// length check ensures that the quote character in the `StartsWith()` check above and the `EndsWith()` check below is not the same character.
|
||||
if (searchTerm.EndsWith("\"!", StringComparison.Ordinal) && searchTerm.Length >= 3)
|
||||
{
|
||||
searchTerm = searchTerm.TrimEnd('!').Trim('\"');
|
||||
MatchMode = MatchMode.FullPhrase;
|
||||
}
|
||||
else
|
||||
{
|
||||
searchTerm = searchTerm.Trim('\"');
|
||||
MatchMode = MatchMode.IsolatedPhrase;
|
||||
}
|
||||
}
|
||||
else
|
||||
MatchMode = MatchMode.Substring;
|
||||
|
Loading…
Reference in New Issue
Block a user