# `MingaEditor.Handlers.BufferRegistry`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_editor/handlers/buffer_registry.ex#L1)

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.

# `state`

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

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

# `add_buffer`

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

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

# `buffer_tracked?`

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

# `do_file_tree_open`

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

# `file_tab_for_path_in_active_workspace`

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

# `find_buffer_by_path`

```elixir
@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`

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

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

# `monitor_buffers`

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

Creates Editor-owned monitors for every untracked buffer pid.

# `open_file_by_path`

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

# `open_file_by_path_result`

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

# `register_buffer`

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

# `register_buffer_background`

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

# `retire_dead_buffer`

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

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

# `start_and_register_file`

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
