feat: right-click context menus in the file-tree sidebar#7
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
fs_opsmodule withrename,create_file,create_dir, andmove_to_trash, each returning a typedFsError(added toerror.rs). Kept out of the UI loop so the validation and disk effects are unit-tested.trashcrate (pinned5.2.6, default features off to avoid pulling inchrono).TreeActionand applied after the tree borrow ends, matching the existingMenuActionpattern.Notes
Reveal in file managershells out to the platform opener (xdg-open/open/explorer) on the containing directory; failures are logged, not fatal.trashcrate is the one new dependency.Verification
cargo fmt --check,cargo clippy --all-targets --all-features -D warnings,cargo test --all(101 pass, +13 new acrossfs_opsandapp), andcargo macheteall 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
TextEditships no built-in context menu, so that one adds rather than replaces.