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.
Summary
Types
Inline editing state for creating files/folders or renaming entries.
File tree sub-state.
Explicit presentation state for the file tree sidebar.
Functions
Accepts the current filter and leaves the narrowed tree visible.
Cancels inline editing, clearing the editing state back to nil.
Clears a pending file tree clipboard operation.
Clears the active filter and exits filtering mode.
Clears the pending filesystem refresh timer reference.
Closes the tree and clears the buffer.
Returns true when inline editing is active.
Marks the sidebar as failed with a displayable reason.
Marks the file tree as focused.
Returns true when the file tree is open and focused.
Hides the file tree help overlay.
Marks the sidebar as loading.
Stores a pending file tree clipboard operation.
Opens the tree with the given data, buffer, and focused state.
Returns true when the file tree is open.
Returns true when a filesystem refresh timer is pending.
Replaces the backing tree and refreshes the presentation status.
Stores the pending filesystem refresh timer reference.
Updates the project root associated with the file tree.
Replaces the tree data.
Enters inline editing mode at the given index.
Starts inline file tree filtering.
Returns the explicit presentation status for the file tree.
Toggles the file tree help overlay.
Marks the file tree as unfocused.
Updates the text being typed in the inline editor.
Updates the active file tree filter.
Returns true when the explicit tree status should occupy the sidebar.
Returns the tree width, preserving the last sidebar width while state-only payloads are visible.
Types
@type clipboard_mark() :: MingaEditor.State.FileTree.ClipboardMark.t()
@type clipboard_operation() :: MingaEditor.State.FileTree.ClipboardMark.operation()
@type editing() :: %{ index: non_neg_integer(), text: String.t(), type: editing_type(), original_name: String.t() | nil }
@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.
@type t() :: %MingaEditor.State.FileTree{ buffer: pid() | nil, clipboard_mark: clipboard_mark() | nil, editing: editing() | nil, filtering: boolean(), focused: boolean(), help_visible: boolean(), original_root: String.t() | nil, project_root: String.t() | nil, refresh_timer: reference() | nil, tree: Minga.Project.FileTree.t() | nil, tree_status: tree_status(), tree_width: pos_integer() }
File tree sub-state.
@type tree_status() :: :hidden | :loading | :empty | :ready | {:error, String.t()}
Explicit presentation state for the file tree sidebar.
Functions
Accepts the current filter and leaves the narrowed tree visible.
Cancels inline editing, clearing the editing state back to nil.
Clears a pending file tree clipboard operation.
Clears the active filter and exits filtering mode.
Clears the pending filesystem refresh timer reference.
Closes the tree and clears the buffer.
Returns true when inline editing is active.
Marks the sidebar as failed with a displayable reason.
Marks the file tree as focused.
Returns true when the file tree is open and focused.
Hides the file tree help overlay.
Marks the sidebar as loading.
Stores a pending file tree clipboard operation.
@spec open(t(), Minga.Project.FileTree.t(), pid() | nil) :: t()
Opens the tree with the given data, buffer, and focused state.
Returns true when the file tree is open.
Returns true when a filesystem refresh timer is pending.
@spec replace_tree(t(), Minga.Project.FileTree.t()) :: t()
Replaces the backing tree and refreshes the presentation status.
Stores the pending filesystem refresh timer reference.
Updates the project root associated with the file tree.
@spec set_tree(t(), Minga.Project.FileTree.t() | nil) :: t()
Replaces the tree data.
@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.
Starts inline file tree filtering.
@spec status(t()) :: tree_status()
Returns the explicit presentation status for the file tree.
Toggles the file tree help overlay.
Marks the file tree as unfocused.
Updates the text being typed in the inline editor.
Updates the active file tree filter.
@spec visible_status?(tree_status()) :: boolean()
Returns true when the explicit tree status should occupy the sidebar.
@spec width(t()) :: pos_integer()
Returns the tree width, preserving the last sidebar width while state-only payloads are visible.