Skip to content
docsv0.3.0

SlashCommandProvider

Slash-command autocomplete provider. Triggers when the cursor follows a `/` that is either at the start of the text or follows whitespace — so `/` inside a file path (`./foo/bar`) does NOT trigger command completion. Suggestions are filtered and ranked via {@see FuzzyMatcher::filter()} so typing `/h` ranks `help` and `history` near the top. The provider is pure-in-memory: the caller hands the command table at construction time and the provider never touches the filesystem.

SlashCommandProvider::__construct()

public function __construct(array $commands):

Parameters

Parameters of __construct()
NameTypeDescription
$commandsarray<int, array{name: string, description?: string}>

SlashCommandProvider::shouldTrigger()

public function shouldTrigger(string $text, int $cursor): bool

Whether the text at the cursor begins a slash command.

Parameters

Parameters of shouldTrigger()
NameTypeDescription
$textstring
$cursorint

SlashCommandProvider::suggestions()

public function suggestions(string $text, int $cursor): array

The commands matching what has been typed after the slash.

Parameters

Parameters of suggestions()
NameTypeDescription
$textstring
$cursorint