# `Minga.Buffer`
[🔗](https://github.com/jsmestad/minga/blob/main/sdk/lib/minga/buffer.ex#L1)

Public API for buffer operations.

Extensions use this module to read buffer content, query cursor
position, check file paths, and manage decorations.

This is a compile-time stub. At runtime, the real module in Minga's
BEAM VM provides the implementation.

# `position`

```elixir
@type position() :: {line :: non_neg_integer(), col :: non_neg_integer()}
```

# `t`

```elixir
@type t() :: GenServer.server()
```

# `batch_decorations`

```elixir
@spec batch_decorations(t(), (term() -&gt; term())) :: :ok
```

# `conflict_count`

```elixir
@spec conflict_count(t()) :: non_neg_integer()
```

# `conflict_snapshot`

```elixir
@spec conflict_snapshot(t()) :: {String.t(), position(), [term()]}
```

# `conflict_view`

```elixir
@spec conflict_view(t()) :: Minga.Buffer.Conflict.view()
```

Returns the cursor, inclusive conflict regions, and their shared buffer version.

# `conflicts`

```elixir
@spec conflicts(t()) :: [term()]
```

# `content`

```elixir
@spec content(t()) :: String.t()
```

# `content_with_version`

```elixir
@spec content_with_version(t()) :: {String.t(), non_neg_integer()}
```

Returns content and its mutation version from the same buffer state.

# `cursor`

```elixir
@spec cursor(t()) :: position()
```

# `decorations`

```elixir
@spec decorations(t()) :: term()
```

# `dirty?`

```elixir
@spec dirty?(t()) :: boolean()
```

# `file_path`

```elixir
@spec file_path(t()) :: String.t() | nil
```

# `filetype`

```elixir
@spec filetype(t()) :: atom()
```

# `get_option`

```elixir
@spec get_option(t(), atom()) :: term()
```

# `line_count`

```elixir
@spec line_count(t()) :: pos_integer()
```

# `lines`

```elixir
@spec lines(t(), non_neg_integer(), non_neg_integer()) :: [String.t()]
```

# `move_to`

```elixir
@spec move_to(t(), position()) :: :ok
```

# `read_only?`

```elixir
@spec read_only?(t()) :: boolean()
```

# `replace_content_if_version`

```elixir
@spec replace_content_if_version(t(), non_neg_integer(), String.t()) ::
  {:ok, non_neg_integer()} | {:error, :read_only | :stale}
```

Replaces the content only at the observed version, returning the new version.

# `resolve_conflict`

```elixir
@spec resolve_conflict(
  t(),
  non_neg_integer(),
  Minga.Buffer.Conflict.target(),
  Minga.Buffer.Conflict.choice()
) ::
  {:ok, Minga.Buffer.Conflict.resolution()}
  | {:error, Minga.Buffer.Conflict.rejection()}
```

Resolves one conflict at the observed version without saving.

# `save_if_version`

```elixir
@spec save_if_version(t(), non_neg_integer()) :: :ok | {:error, term()}
```

Saves the file only when the buffer is still at the requested version.

---

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