# `Minga.Editing.NavigableContent.BufferSnapshot`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga/editing/navigable_content/buffer_snapshot.ex#L1)

NavigableContent adapter for `Buffer.Document` snapshots.

Wraps a `Document.t()` and a `Scroll.t()` into a single struct that
implements both `NavigableContent` and `Readable`. This is the bridge
between the Buffer domain (gap buffer, byte-indexed columns, undo
stack) and the universal editing model (protocol-based commands).

## Usage

    # Take a snapshot from a running Buffer.Server
    doc = Buffer.Server.snapshot(server)
    snapshot = BufferSnapshot.new(doc, scroll)

    # Commands operate on the snapshot
    pos = Motion.word_forward(snapshot, NavigableContent.cursor(snapshot))
    snapshot = NavigableContent.set_cursor(snapshot, pos)

    # Apply the result back
    Buffer.Server.apply_snapshot(server, snapshot.document)

## Coordinate system

Columns are byte offsets, matching `Document`'s convention. This is
consistent with tree-sitter and the Zig renderer. Use
`Document.grapheme_col/2` when you need display column widths.

# `t`

```elixir
@type t() :: %Minga.Editing.NavigableContent.BufferSnapshot{
  document: Minga.Buffer.Document.t(),
  scroll: Minga.Editing.Scroll.t()
}
```

A Document snapshot with scroll state for NavigableContent.

# `new`

```elixir
@spec new(Minga.Buffer.Document.t()) :: t()
```

Creates a new BufferSnapshot from a Document and optional Scroll state.

# `new`

```elixir
@spec new(Minga.Buffer.Document.t(), Minga.Editing.Scroll.t()) :: t()
```

---

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