Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle searches for labels with spaces #3374

Merged
merged 1 commit into from
May 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions GUI/Model/ModSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private string getCombined()
}
foreach (var label in Labels)
{
pieces.Add($"{Properties.Resources.ModSearchLabelPrefix}{label.Name}");
pieces.Add($"{Properties.Resources.ModSearchLabelPrefix}{label.Name.Replace(" ", "")}");
}
if (Compatible.HasValue)
{
Expand Down Expand Up @@ -306,7 +306,13 @@ public static ModSearch Parse(string combined, List<ModuleLabel> knownLabels)
}
else if (TryPrefix(s, Properties.Resources.ModSearchLabelPrefix, out string labelName))
{
labels.AddRange(knownLabels.Where(lb => lb.Name == labelName));
labels.AddRange(
// Label searches exclude spaces, but label names can include them
knownLabels.Where(lb => lb.Name.Replace(" ", "") == labelName)
// If label doesn't exist, maybe it will be created later or the user is still typing.
// Make an unofficial label object to accurately reflect the search.
.DefaultIfEmpty(new ModuleLabel() { Name = labelName })
);
}
else if (TryPrefix(s, Properties.Resources.ModSearchYesPrefix, out string yesSuffix))
{
Expand Down