AutocompleteOverlay
Category: UI
Source: autocomplete_overlay.dart
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
const AcceptResult(this.text, this.cursor)Properties
| Property | Type | Description |
|---|---|---|
text | String | |
cursor | int |
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] —
@filereference 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
| Property | Type | Description |
|---|---|---|
active | bool get | Whether the overlay is currently shown and intercepting input. |
selected | int get | Index of the currently highlighted match. |
matchCount | int get | Number of matches currently displayed. |
overlayHeight | int get | Rows the overlay occupies when rendered. |
matchCount | int get | Number of matches currently displayed. |
selected | int get | Index of the currently highlighted match. |
scrollOffset | int get | First match index visible in the render window. |
overlayHeight | int get | Rows the overlay occupies: the match count, capped at one screenful. |
active | bool get | Whether the overlay is currently shown and intercepting input. |
selected | int get | Index of the currently highlighted match. |
matchCount | int get | Number of matches currently displayed. |
overlayHeight | int get | Rows the overlay occupies when rendered. |
matchCount | int get | Number of matches currently displayed. |
selected | int get | Index of the currently highlighted match. |
scrollOffset | int get | First match index visible in the render window. |
overlayHeight | int get | Rows the overlay occupies: the match count, capped at one screenful. |
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].
void resetSelection()
Put the cursor back at the top. Call after rebuilding the match list.
void clampSelectionToMatches()
Keep the selection in range after the match list was rebuilt, and put the render window back at the top.
void moveUp()
AutocompleteSelection
Selection and viewport state shared by the three overlays.
They differ entirely in how they build their match list and not at all in how the user moves through it, so [moveUp], [moveDown], the scroll clamp and [overlayHeight] live here. Implementers supply [matchCount] and reset the cursor with [resetSelection] whenever the list changes.
Properties
| Property | Type | Description |
|---|---|---|
matchCount | int get | Number of matches currently displayed. |
selected | int get | Index of the currently highlighted match. |
scrollOffset | int get | First match index visible in the render window. |
overlayHeight | int get | Rows the overlay occupies: the match count, capped at one screenful. |
matchCount | int get | Number of matches currently displayed. |
selected | int get | Index of the currently highlighted match. |
scrollOffset | int get | First match index visible in the render window. |
overlayHeight | int get | Rows the overlay occupies: the match count, capped at one screenful. |
Methods
void resetSelection()
Put the cursor back at the top. Call after rebuilding the match list.
void clampSelectionToMatches()
Keep the selection in range after the match list was rebuilt, and put the render window back at the top.
void moveUp()
void moveDown()
void clampScroll()
Slide the render window so [selected] stays inside it.