diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-04-13 22:06:07 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-04-13 22:06:07 -0400 |
commit | 2765e3f9b379f0dc2a5732c1ca9ba23dbe2a7f15 (patch) | |
tree | 3b97dd4aa6e9b7971dafa139c64a39c31e841fe6 /src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/ListItemsCommand.cs | |
parent | aa7b0caf4656d65ee156c3cf5ea786f561b850bb (diff) | |
download | SMAPI-2765e3f9b379f0dc2a5732c1ca9ba23dbe2a7f15.tar.gz SMAPI-2765e3f9b379f0dc2a5732c1ca9ba23dbe2a7f15.tar.bz2 SMAPI-2765e3f9b379f0dc2a5732c1ca9ba23dbe2a7f15.zip |
enable nullable annotations in bundled mods (#837)
Diffstat (limited to 'src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/ListItemsCommand.cs')
-rw-r--r-- | src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/ListItemsCommand.cs | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/ListItemsCommand.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/ListItemsCommand.cs index 5a21b459..73d5b79d 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/ListItemsCommand.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/Commands/Player/ListItemsCommand.cs @@ -1,5 +1,3 @@ -#nullable disable - using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -63,15 +61,14 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework.Commands.Player private IEnumerable<SearchableItem> GetItems(string[] searchWords) { // normalize search term - searchWords = searchWords?.Where(word => !string.IsNullOrWhiteSpace(word)).ToArray(); - if (searchWords?.Any() == false) - searchWords = null; + searchWords = searchWords.Where(word => !string.IsNullOrWhiteSpace(word)).ToArray(); + bool getAll = !searchWords.Any(); // find matches return ( from item in this.Items.GetAll() let term = $"{item.ID}|{item.Type}|{item.Name}|{item.DisplayName}" - where searchWords == null || searchWords.All(word => term.IndexOf(word, StringComparison.CurrentCultureIgnoreCase) != -1) + where getAll || searchWords.All(word => term.IndexOf(word, StringComparison.CurrentCultureIgnoreCase) != -1) select item ); } |