Skip to content
docsv0.3.0

CombinedAutocompleteProvider

Combined autocomplete provider for slash commands and file paths. The PHP analog of pi-tui's `CombinedAutocompleteProvider`. Delegates to a {@see SlashCommandProvider} when the cursor follows a `/` not preceded by a non-whitespace char, and to a {@see FilePathProvider} when the cursor is inside a `./`, `~/`, `../`, or `@`-prefixed token. When neither applies, answers no completions. Both sub-providers rank matches via {@see FuzzyMatcher::filter()} so the user can type loose substrings and still see the right entries float to the top. The combined provider does NOT merge results from both sub-providers — at most one fires per cursor position, mirroring pi-tui's "type `/` for commands, Tab for files" UX.

CombinedAutocompleteProvider::__construct()

public function __construct(Milpa\Live\Tui\SlashCommandProvider $commands, Milpa\Live\Tui\FilePathProvider $files):

Parameters

Parameters of __construct()
NameTypeDescription
$commandsMilpa\Live\Tui\SlashCommandProvider
$filesMilpa\Live\Tui\FilePathProvider

CombinedAutocompleteProvider::shouldTrigger()

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

Whether any of the combined providers wants to complete at this cursor.

Parameters

Parameters of shouldTrigger()
NameTypeDescription
$textstring
$cursorint

CombinedAutocompleteProvider::suggestions()

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

The suggestions of every provider that triggers, in provider order.

Parameters

Parameters of suggestions()
NameTypeDescription
$textstring
$cursorint

CombinedAutocompleteProvider::acceptSuggestion()

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

Replaces the complete token around the cursor with a selected value.

Parameters

Parameters of acceptSuggestion()
NameTypeDescription
$textstring
$cursorint
$valuestring