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 CommandSearch

Remarks

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:

  1. Walk through the command name character by character.

  2. For each character, check if it matches the next unmatched character in the input.

  3. Record matches in a bool[] matchTable (same length as command name).

  4. If all input characters are matched before the command name ends → match found.

  5. 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:

Character
Formula
Effect

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 matches

  • Shorter 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.

Parameter
Type
Description

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

Last updated