MingaEditor.Handlers.BufferRegistry (Minga v0.1.0)

Copy Markdown View Source

Buffer registration and lookup: opening files, tracking buffers in the workspace, and deduplicating tab entries.

Changes when: how we open, register, or track buffers changes.

Summary

Types

Editor state (same as MingaEditor.state()).

Functions

Applies the pure buffer-registration transition and creates its requested monitor.

Returns the index of the live buffer whose canonical path matches.

Creates one Editor-owned monitor and records its correlation reference.

Creates Editor-owned monitors for every untracked buffer pid.

Runs external cleanup around the pure retired-buffer root transition.

Types

state()

@type state() :: MingaEditor.State.t()

Editor state (same as MingaEditor.state()).

Functions

add_buffer(state, pid, opts \\ [])

@spec add_buffer(state(), pid(), keyword()) :: state()

Applies the pure buffer-registration transition and creates its requested monitor.

buffer_tracked?(state, pid)

@spec buffer_tracked?(state(), pid()) :: boolean()

do_file_tree_open(state, pid, path, tree)

@spec do_file_tree_open(state(), pid(), String.t(), Minga.Project.FileTree.t()) ::
  state()

file_tab_for_path_in_active_workspace(state, path)

@spec file_tab_for_path_in_active_workspace(state(), String.t()) ::
  MingaEditor.State.Tab.t() | nil

find_buffer_by_path(map, file_path)

@spec find_buffer_by_path(state() | map(), String.t()) :: non_neg_integer() | nil

Returns the index of the live buffer whose canonical path matches.

monitor_buffer(state, pid)

@spec monitor_buffer(state(), pid() | term()) :: state()

Creates one Editor-owned monitor and records its correlation reference.

monitor_buffers(state, pids)

@spec monitor_buffers(state(), [pid()]) :: state()

Creates Editor-owned monitors for every untracked buffer pid.

open_file_by_path(state, abs_path)

@spec open_file_by_path(state(), String.t()) :: state()

open_file_by_path_result(state, abs_path)

@spec open_file_by_path_result(state(), String.t()) ::
  {:ok, state()} | {:error, term()}

register_buffer(state, buffer_pid, file_path)

@spec register_buffer(state(), pid(), String.t()) :: state()

register_buffer_background(state, buffer_pid, file_path)

@spec register_buffer_background(state(), pid(), String.t()) :: state()

retire_dead_buffer(state, pid)

@spec retire_dead_buffer(state(), pid()) :: state()

Runs external cleanup around the pure retired-buffer root transition.

start_and_register_file(state, abs_path)

@spec start_and_register_file(state(), String.t()) ::
  {:ok, state()} | {:error, term()}