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

open_or_activate_option()

@type open_or_activate_option() ::
  {:existing_target, :buffer | :tab}
  | {:options_server, GenServer.server() | nil}
  | {:start_opts, keyword()}

open_or_activate_result()

@type open_or_activate_result() ::
  {:ok, state(), pid(), open_or_activate_status()} | {:error, term()}

open_or_activate_status()

@type open_or_activate_status() :: :opened | :activated | :switched_tab

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_inventory(state)

@spec buffer_inventory(state()) :: [pid()]

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()}

open_or_activate_path(state, abs_path, opts \\ [])

@spec open_or_activate_path(state(), String.t(), [open_or_activate_option()]) ::
  open_or_activate_result()

register_buffer(state, buffer_pid, file_path, opts \\ [])

@spec register_buffer(state(), pid(), String.t(), keyword()) :: 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()}