# `MingaEditor.State.FileTree`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga_editor/state/file_tree.ex#L1)

File tree sub-state: tree data, focus, and backing buffer.

Wraps the file-tree-related fields from EditorState into a single
struct with query and mutation helpers. Includes inline editing state
for new file, new folder, and rename operations.

# `editing`

```elixir
@type editing() :: %{
  index: non_neg_integer(),
  text: String.t(),
  type: editing_type(),
  original_name: String.t() | nil
}
```

# `editing_type`

```elixir
@type editing_type() :: :new_file | :new_folder | :rename
```

Inline editing state for creating files/folders or renaming entries.

When non-nil, the user is actively typing a filename in the tree.
The `index` is the visual position in the visible entry list where
the editing row appears. For new file/folder, this is the insertion
point. For rename, this is the entry being renamed.

# `t`

```elixir
@type t() :: %MingaEditor.State.FileTree{
  buffer: pid() | nil,
  editing: editing() | nil,
  focused: boolean(),
  project_root: String.t() | nil,
  tree: Minga.Project.FileTree.t() | nil
}
```

File tree sub-state.

# `cancel_editing`

```elixir
@spec cancel_editing(t()) :: t()
```

Cancels inline editing, clearing the editing state back to nil.

# `close`

```elixir
@spec close(t()) :: t()
```

Closes the tree and clears the buffer.

# `editing?`

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

Returns true when inline editing is active.

# `focused?`

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

Returns true when the file tree is open and focused.

# `open`

```elixir
@spec open(t(), Minga.Project.FileTree.t(), pid() | nil) :: t()
```

Opens the tree with the given data, buffer, and focused state.

# `open?`

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

Returns true when the file tree is open.

# `start_editing`

```elixir
@spec start_editing(t(), non_neg_integer(), editing_type(), String.t()) :: t()
```

Enters inline editing mode at the given index.

For new file/folder, `initial_text` is empty. For rename,
`initial_text` is the current entry name.

# `update_editing_text`

```elixir
@spec update_editing_text(t(), String.t()) :: t()
```

Updates the text being typed in the inline editor.

# `width`

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

Returns the tree width, or 0 if the tree is not open.

---

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