MingaEditor.State.Tab.Context (Minga v0.1.0)

Copy Markdown View Source

Typed per-tab workspace snapshot stored on MingaEditor.State.Tab.

Contexts replace the old free-form map while still accepting legacy maps at API boundaries. present_fields records which workspace fields were actually present in a legacy map so partial migration inputs do not overwrite live workspace state with nil defaults.

Summary

Types

A document highlight range from the LSP server.

Workspace fields carried by a tab context.

Legacy map persisted or built before tab contexts became typed structs.

t()

Functions

Returns an empty context for a brand-new tab with no saved workspace yet.

Returns true when the context has no workspace fields to restore.

Returns the workspace field names represented by this context.

Normalizes a legacy context map into a typed context struct.

Creates a tab context directly from a workspace struct, without intermediate map conversion.

Returns a context with valid workspace field overrides applied.

Returns a context with the dead buffer removed from its buffers snapshot when present.

Returns a workspace map containing only fields present in this context.

Types

document_highlight()

@type document_highlight() :: Minga.LSP.DocumentHighlight.t()

A document highlight range from the LSP server.

field_name()

@type field_name() ::
  :keymap_scope
  | :buffers
  | :windows
  | :dired
  | :file_tree
  | :viewport
  | :mouse
  | :highlight
  | :lsp_pending
  | :injection_ranges
  | :search
  | :editing
  | :feature_state
  | :document_highlights
  | :agent_ui

Workspace fields carried by a tab context.

legacy()

@type legacy() :: map()

Legacy map persisted or built before tab contexts became typed structs.

t()

@type t() :: %MingaEditor.State.Tab.Context{
  agent_ui: MingaEditor.Agent.UIState.t() | nil,
  buffers: MingaEditor.State.Buffers.t() | nil,
  dired: MingaEditor.State.Dired.t() | nil,
  document_highlights: [document_highlight()] | nil,
  editing: MingaEditor.VimState.t() | nil,
  feature_state: MingaEditor.FeatureState.t() | nil,
  file_tree: MingaEditor.State.FileTree.t() | nil,
  highlight: MingaEditor.State.Highlighting.t() | nil,
  injection_ranges:
    %{required(pid()) => [Minga.Language.Highlight.InjectionRange.t()]} | nil,
  keymap_scope: Minga.Keymap.Scope.scope_name() | nil,
  lsp_pending: %{required(reference()) => atom() | tuple()} | nil,
  mouse: MingaEditor.State.Mouse.t() | nil,
  present_fields: [field_name()],
  search: MingaEditor.State.Search.t() | nil,
  version: pos_integer(),
  viewport: MingaEditor.Viewport.t() | nil,
  windows: MingaEditor.State.Windows.t() | nil
}

Functions

empty()

@spec empty() :: t()

Returns an empty context for a brand-new tab with no saved workspace yet.

empty?(context)

@spec empty?(t() | legacy()) :: boolean()

Returns true when the context has no workspace fields to restore.

field_names()

@spec field_names() :: [field_name()]

Returns the workspace field names represented by this context.

from_map(context)

@spec from_map(t() | legacy()) :: t()

Normalizes a legacy context map into a typed context struct.

from_workspace(ws)

@spec from_workspace(MingaEditor.Session.State.t()) :: t()

Creates a tab context directly from a workspace struct, without intermediate map conversion.

from_workspace_map(map)

This function is deprecated. Use from_workspace/1 for struct inputs. This remains for legacy map inputs only..
@spec from_workspace_map(map()) :: t()

put_fields(context, attrs)

@spec put_fields(t(), map() | keyword()) :: t()

Returns a context with valid workspace field overrides applied.

scrub_buffer(context, pid)

@spec scrub_buffer(t() | legacy(), pid()) :: t()

Returns a context with the dead buffer removed from its buffers snapshot when present.

to_workspace_map(context)

@spec to_workspace_map(t() | legacy()) :: map()

Returns a workspace map containing only fields present in this context.