Skip to content

AutocompleteOverlay

Category: UI

Source: autocomplete_overlay.dart

Result of accepting an autocomplete suggestion.

Represents the full new buffer contents and the absolute cursor position within it. Each overlay computes its own splicing strategy and returns the result, so the router can apply it uniformly with editor.setText(result.text, cursor: result.cursor).

Classes

AcceptResult

Result of accepting an autocomplete suggestion.

Represents the full new buffer contents and the absolute cursor position within it. Each overlay computes its own splicing strategy and returns the result, so the router can apply it uniformly with editor.setText(result.text, cursor: result.cursor).

Constructor

dart
const AcceptResult(this.text, this.cursor)

Properties

PropertyTypeDescription
textString
cursorint

abstract AutocompleteOverlay

Common contract for in-input autocomplete overlays.

Three implementations live in cli/lib/src/ui/:

  • [SlashAutocomplete] — command palette triggered by /
  • [ShellAutocomplete] — tab completion triggered inside bash mode
  • [AtFileHint] — @file reference hint

The router dispatches Up/Down/Tab/Enter/Esc to whichever overlay is currently [active]. Trigger semantics (how an overlay becomes active in the first place) differ per overlay and are NOT part of this interface — each overlay keeps its own update/requestCompletions entry point.

Properties

PropertyTypeDescription
activebool getWhether the overlay is currently shown and intercepting input.
selectedint getIndex of the currently highlighted match.
matchCountint getNumber of matches currently displayed.
overlayHeightint getRows the overlay occupies when rendered.
activebool getWhether the overlay is currently shown and intercepting input.
selectedint getIndex of the currently highlighted match.
matchCountint getNumber of matches currently displayed.
overlayHeightint getRows the overlay occupies when rendered.

Methods

void moveUp()

Move selection up (wraps).

void moveDown()

Move selection down (wraps).

AcceptResult? accept(String buffer, int cursor)

Accept the current selection, given the editor's current [buffer] and absolute [cursor] position. Returns the new buffer + cursor, or null if nothing to accept.

void dismiss()

Hide the overlay and reset state.

List<String> render(int width)

Render the overlay as styled lines for the given [width].

Released under the MIT License.