You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GetCommandsByCategory(null) returns nothing, while "" and " " return the uncategorized commands #140
c.Category is a CommandCategory?, which is a SemanticString. Passing it to string.Equals(string, string, …) goes through the implicit string conversion, and a null CommandCategory converts to "", not null. That gives three different results:
category: null: compares "" with null, so nothing ever matches.
category: "" or " ": trims to "", so it matches every uncategorized command.
Repro
Register two commands:
new Command("file.save", "Save"), with no category
The parameter is declared string? category, so null is an intended input, and "commands with no category" is the natural meaning. A UI that groups commands by category and passes command.Category back in gets an empty "Uncategorized" group.
Suggested fix / acceptance criteria
Handle null explicitly instead of relying on the implicit conversion:
string?wanted=string.IsNullOrWhiteSpace(category)?null:category.Trim();.Where(c =>wantedisnull?c.Categoryisnull:c.Categoryis not null&&string.Equals(c.Category.ToString(),wanted,StringComparison.OrdinalIgnoreCase))
Null, "" and whitespace all return the uncategorized commands, and no others.
Priority: Low. The workaround is to pass "". The visible effect is an empty "Uncategorized" group in a UI that passes command.Category back in.
Area / suggested assignee:CommandRegistry.GetCommandsByCategory (Keybinding/Services/CommandRegistry.cs). The cause is the implicit SemanticString-to-string conversion turning a null CommandCategory into "". Owner: @matt-edmondson
Next step: apply the explicit null handling from the issue and add the four tests (null, "", " ", "Edit"). Look for other string.Equals calls on nullable SemanticStrings in this repo, since they have the same trap.
Activity
matt-edmondson commentedon Sep 27, 2026
Triage
"". The visible effect is an empty "Uncategorized" group in a UI that passescommand.Categoryback in.CommandRegistry.GetCommandsByCategory(Keybinding/Services/CommandRegistry.cs). The cause is the implicit SemanticString-to-string conversion turning a nullCommandCategoryinto"". Owner: @matt-edmondsonCommandconstructor and profile pruning.""," ","Edit"). Look for otherstring.Equalscalls on nullable SemanticStrings in this repo, since they have the same trap.Generated by Claude Code