CommandSearch
Internal static utility that performs fuzzy substring matching against registered commands. Implements a case-insensitive subsequence algorithm with a weighted scoring system that favors early-position matches and uppercase (CamelCase boundary) hits. Returns sorted CommandSearchResult instances with per-character match tables for rich text highlighting.
Definition
Namespace: Paragon.Core.Command Assembly: Paragon.dll
internal static class CommandSearchRemarks
CommandSearch is the engine behind Command.Search() and the CommandToolbar. It differs from CommandProvider.GetMatchingCommands() by providing scored, sorted results with match metadata, rather than a simple pass/fail filter.
Fuzzy Matching Algorithm
The EvaluateMatch method performs case-insensitive subsequence matching:
Walk through the command name character by character.
For each character, check if it matches the next unmatched character in the input.
Record matches in a
bool[] matchTable(same length as command name).If all input characters are matched before the command name ends → match found.
If the command name ends before all input characters are matched → no match.
Scoring Algorithm
The EvaluateScore method assigns a weighted score based on match positions:
Matched
+(50 - index) × 10 × (isUpper ? 2 : 1)
Earlier matches and uppercase matches score higher
Unmatched
-(50 - index) × 5
Earlier gaps penalize more
This scoring naturally ranks:
Prefix matches above mid-string matches
CamelCase boundary matches (e.g.,
"EP"matching"EnterPlayMode") above lowercase matchesShorter gaps above longer gaps
Runtime Filtering
Commands marked RuntimeOnly = true are excluded from results when Application.isPlaying is false, preventing editor-time access to runtime-only commands.
Methods
GetAllMatchingName
Returns all commands that fuzzy-match the given input, sorted by descending score.
name
string
The user's input to match against command names
Returns: Sorted CommandSearchResult enumerable. Empty if name is null or empty.
Examples
How Scoring Works
See Also
CommandSearchResult — the result record with match metadata
CommandProvider — the command registry searched against
CommandToolbar — the UI that uses search results
Command System — system overview
Last updated