Skip to content

feat: right-click context menus in the file-tree sidebar#7

Merged
fredclausen merged 1 commit into
mainfrom
sidebar-context-menu
Jun 30, 2026
Merged

feat: right-click context menus in the file-tree sidebar#7
fredclausen merged 1 commit into
mainfrom
sidebar-context-menu

Conversation

@fredclausen

Copy link
Copy Markdown
Member

What

Adds right-click context menus to the workspace sidebar (first of two PRs; the editor context menu follows).

File rows: Open, Copy path, Copy relative path, Reveal in file manager, Rename, Delete (move to trash).

Folder rows (and the empty tree area, which targets the workspace root): New file, New folder, Copy path, Copy relative path, Reveal in file manager, Rename, Delete (move to trash).

How

  • New fs_ops module with rename, create_file, create_dir, and move_to_trash, each returning a typed FsError (added to error.rs). Kept out of the UI loop so the validation and disk effects are unit-tested.
  • Name entry (rename / new file / new folder) uses a modal dialog mirroring the existing unsaved-changes prompt; invalid names and clobber attempts surface inline and keep the modal open.
  • Delete goes to the OS trash (recoverable) via the trash crate (pinned 5.2.6, default features off to avoid pulling in chrono).
  • Editor/workspace reconciliation:
    • Renaming a file or directory repoints any open tab whose path lived at or under it, and migrates matching entries in the workspace expanded-folder set.
    • Trashing a path closes the tabs it backed and prunes now-stale expanded entries.
  • Menu choices are collected into a deferred TreeAction and applied after the tree borrow ends, matching the existing MenuAction pattern.

Notes

  • Reveal in file manager shells out to the platform opener (xdg-open / open / explorer) on the containing directory; failures are logged, not fatal.
  • The trash crate is the one new dependency.

Verification

cargo fmt --check, cargo clippy --all-targets --all-features -D warnings, cargo test --all (101 pass, +13 new across fs_ops and app), and cargo machete all green in the Nix dev shell. Release build compiles.

Follow-up

Editor context menu (Cut/Copy/Paste/Select All + Find/Find & Replace/Save) in a second PR \u2014 egui's TextEdit ships no built-in context menu, so that one adds rather than replaces.

Add context menus to the sidebar: right-clicking a file offers Open, Copy
path, Copy relative path, Reveal in file manager, Rename, and Delete (to
trash); right-clicking a folder (or the empty tree area, which targets the
root) offers New file, New folder, the same copy/reveal entries, Rename,
and Delete.

Filesystem operations live in a new fs_ops module (rename, create file,
create dir, move-to-trash) returning a typed FsError, kept out of the UI
loop so they are unit-testable. Rename and create names are collected
through a modal dialog mirroring the existing unsaved-changes prompt;
deletes go to the OS trash (recoverable) via the trash crate.

Editor state is reconciled with disk changes: renaming a file or directory
repoints any open tab whose path lived at or under it and migrates the
workspace expanded-folder set; trashing a path closes the tabs it backed
and prunes stale expanded entries. Menu choices are collected into a
deferred TreeAction and applied after the tree borrow ends, matching the
existing MenuAction pattern.
@fredclausen
fredclausen merged commit fd1484a into main Jun 30, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant