mirror of
https://github.com/ppy/osu.git
synced 2025-01-07 21:32:57 +08:00
Fix song select status prefix matching no longer working
Regressed in #19275 due to weird logic. Closes #20289.
This commit is contained in:
parent
ef6d60ffe9
commit
b4e6a20846
@ -191,6 +191,16 @@ namespace osu.Game.Tests.NonVisual.Filtering
|
|||||||
Assert.IsTrue(filterCriteria.BeatDivisor.IsUpperInclusive);
|
Assert.IsTrue(filterCriteria.BeatDivisor.IsUpperInclusive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestPartialStatusMatch()
|
||||||
|
{
|
||||||
|
const string query = "status=r";
|
||||||
|
var filterCriteria = new FilterCriteria();
|
||||||
|
FilterQueryParser.ApplyQueries(filterCriteria, query);
|
||||||
|
Assert.AreEqual(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Min);
|
||||||
|
Assert.AreEqual(BeatmapOnlineStatus.Ranked, filterCriteria.OnlineStatus.Max);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestApplyStatusQueries()
|
public void TestApplyStatusQueries()
|
||||||
{
|
{
|
||||||
|
@ -122,14 +122,17 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private static bool tryParseEnum<TEnum>(string value, out TEnum result) where TEnum : struct
|
private static bool tryParseEnum<TEnum>(string value, out TEnum result) where TEnum : struct
|
||||||
{
|
{
|
||||||
if (Enum.TryParse(value, true, out result)) return true;
|
// First try an exact match.
|
||||||
|
if (Enum.TryParse(value, true, out result))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Then try a prefix match.
|
||||||
string? prefixMatch = Enum.GetNames(typeof(TEnum)).FirstOrDefault(name => name.StartsWith(value, true, CultureInfo.InvariantCulture));
|
string? prefixMatch = Enum.GetNames(typeof(TEnum)).FirstOrDefault(name => name.StartsWith(value, true, CultureInfo.InvariantCulture));
|
||||||
|
|
||||||
if (prefixMatch == null)
|
if (prefixMatch == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return Enum.TryParse(value, true, out result);
|
return Enum.TryParse(prefixMatch, true, out result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static GroupCollection? tryMatchRegex(string value, string regex)
|
private static GroupCollection? tryMatchRegex(string value, string regex)
|
||||||
|
Loading…
Reference in New Issue
Block a user