From 1501bd4fbf5b05be2b770b0e1b8b856d71f1dce3 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Mon, 22 Jul 2024 12:41:20 +0200 Subject: [PATCH] Fix negative matching on folders with no matches. --- Penumbra/UI/ModsTab/ModSearchStringSplitter.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Penumbra/UI/ModsTab/ModSearchStringSplitter.cs b/Penumbra/UI/ModsTab/ModSearchStringSplitter.cs index 1ea70731..e7550eea 100644 --- a/Penumbra/UI/ModsTab/ModSearchStringSplitter.cs +++ b/Penumbra/UI/ModsTab/ModSearchStringSplitter.cs @@ -95,9 +95,9 @@ public sealed class ModSearchStringSplitter : SearchStringSplitter MatchesName(i, folder.Name, fullName)) - && !Negated.Any(i => MatchesName(i, folder.Name, fullName)) - && (General.Count == 0 || General.Any(i => MatchesName(i, folder.Name, fullName))); + return Forced.All(i => MatchesName(i, folder.Name, fullName, false)) + && !Negated.Any(i => MatchesName(i, folder.Name, fullName, true)) + && (General.Count == 0 || General.Any(i => MatchesName(i, folder.Name, fullName, false))); } protected override bool Matches(Entry entry, ModFileSystem.Leaf leaf) @@ -128,11 +128,11 @@ public sealed class ModSearchStringSplitter : SearchStringSplitter true, }; - private static bool MatchesName(Entry entry, ReadOnlySpan name, ReadOnlySpan fullName) + private static bool MatchesName(Entry entry, ReadOnlySpan name, ReadOnlySpan fullName, bool defaultValue) => entry.Type switch { ModSearchType.Default => fullName.Contains(entry.Needle, StringComparison.OrdinalIgnoreCase), ModSearchType.Name => name.Contains(entry.Needle, StringComparison.OrdinalIgnoreCase), - _ => false, + _ => defaultValue, }; }