MingaEditor.State.ModalOverlay.Completion (Minga v0.1.0)

Copy Markdown View Source

Modal-overlay payload for the completion menu.

The completion menu is logically per-tab: it tracks the cursor position of the buffer that triggered it. The owner field carries the tab identifier so the tab-switch hook (MingaEditor.Shell.Traditional.ModalWorkflow.dismiss_if_stale/1) can auto-dismiss completion that no longer belongs to the active tab.

Trigger lifecycle

The completion trigger (debounce/pending-ref machinery) is part of the modal's lifecycle: it only matters while completion is being driven, and resets when completion dismisses. Carrying the trigger on the payload — rather than as an independent field on workspace state — keeps the modal's lifecycle self-contained and removes a per-tab field that other callers had to know about.

Summary

Types

The user-visible completion menu, or nil while a request is pending.

Identifier of the tab that triggered completion.

t()

Functions

Builds a completion payload bound to owner (typically a tab id).

Replaces the inner Completion.t() on the payload, preserving owner, trigger, and opened_at. The only sanctioned way to update completion state from outside this module (Rule 2: state ownership).

Replaces the inner trigger on the payload. The only sanctioned way to update the trigger from outside this module.

Types

completion_or_nil()

@type completion_or_nil() :: Minga.Editing.Completion.t() | nil

The user-visible completion menu, or nil while a request is pending.

nil represents the brief window between the trigger firing an LSP request and the response arriving. The render layer paints nothing while completion is nil; the modal exists so the trigger's debounce/ pending-ref state has a home.

owner()

@type owner() :: MingaEditor.State.Tab.id() | nil

Identifier of the tab that triggered completion.

Tab IDs are the positive integer keys of MingaEditor.State.TabBar's tab map. nil is valid while completion-trigger work starts before a tab is available.

t()

@type t() :: %MingaEditor.State.ModalOverlay.Completion{
  completion: completion_or_nil(),
  opened_at: integer(),
  owner: owner(),
  trigger: MingaEditor.CompletionTrigger.t()
}

Functions

new(owner, opts \\ [])

@spec new(
  owner(),
  keyword()
) :: t()

Builds a completion payload bound to owner (typically a tab id).

Pass :completion to seed an already-resolved completion menu, or omit to open a payload that just tracks the trigger lifecycle while an LSP request is in flight.

put_completion(payload, completion)

@spec put_completion(t(), completion_or_nil()) :: t()

Replaces the inner Completion.t() on the payload, preserving owner, trigger, and opened_at. The only sanctioned way to update completion state from outside this module (Rule 2: state ownership).

put_trigger(payload, trigger)

@spec put_trigger(t(), MingaEditor.CompletionTrigger.t()) :: t()

Replaces the inner trigger on the payload. The only sanctioned way to update the trigger from outside this module.