Skip to content
docsv0.3.0

FilePathProvider

File-path autocomplete provider. Triggers when the cursor is inside a token that starts with `./`, `~/`, `../`, or `@` (the same prefixes pi-tui recognizes). The provider lists the files inside the directory implied by the prefix and filters them via {@see FuzzyMatcher::filter()} on the basename. Pure-in-memory: the caller supplies a `callable(string $dir): array` directory lister so the provider itself does not call `opendir()` — this keeps it pure and testable, and lets a real harness swap in a cached or async-backed lister later. The lister returns an array of `{name: string, isDir: bool}` entries; the provider shapes them into `select-list` items with a trailing `/` for directories.

FilePathProvider::__construct()

public function __construct(Closure $lister):

Parameters

Parameters of __construct()
NameTypeDescription
$lister\Closure(string): array<int, array{name: string, isDir: bool}>

FilePathProvider::shouldTrigger()

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

Whether the text at the cursor begins a path worth completing.

Parameters

Parameters of shouldTrigger()
NameTypeDescription
$textstring
$cursorint

FilePathProvider::suggestions()

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

The paths matching the fragment at the cursor.

Parameters

Parameters of suggestions()
NameTypeDescription
$textstring
$cursorint