project_panel: Select the whole folder name when renaming - #59390
Merged
MrSubidubi merged 2 commits intoJun 16, 2026
Merged
Conversation
Path::file_stem treated a folder's trailing ".suffix" as a file extension, so renaming a folder with a dot in its name only pre-selected the text before the last dot. Select the whole name for directories; files keep their extension unselected.
IbrahimKhan12
force-pushed
the
fix/project-panel-folder-rename-selection
branch
from
June 15, 2026 23:16
b7ce6c1 to
10bf8b2
Compare
IbrahimKhan12
marked this pull request as ready for review
June 15, 2026 23:17
MrSubidubi
reviewed
Jun 16, 2026
MrSubidubi
approved these changes
Jun 16, 2026
MrSubidubi
left a comment
Member
There was a problem hiding this comment.
Nice fix, thanks for this and congrats to your first contribution! 🎉
This was referenced Jun 18, 2026
Closed
This was referenced Jul 1, 2026
This was referenced Jul 10, 2026
jolutz
pushed a commit
to jolutz/zed
that referenced
this pull request
Aug 8, 2026
…ries#59390) # Objective - Renaming a folder whose name contains a dot pre-selects only the text before the last dot, treating the suffix as if it were a file extension. - Fixes zed-industries#59294 ## Solution - `ProjectPanel::rename_impl` computed the rename editor's initial selection with `Path::file_stem().len()` for every entry. For a directory such as `my.folder`, `file_stem()` returns `my`, so only `my` was selected. - Directories have no extension, so select the whole name for them. Files keep the existing behavior (the last extension is left unselected for quick renames). ## Testing - Added `test_rename_folder_with_dot_selects_whole_name` in `project_panel_tests.rs`. It fails before the change (folder selection ends at offset 2 of `my.folder`) and passes after (offset 9, the whole name); it also asserts a file still leaves the last extension unselected. - `cargo test -p project_panel` — all 100 tests pass. - `cargo clippy -p project_panel --all-targets --all-features -- --deny warnings` and `cargo fmt -p project_panel -- --check` are clean. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards (UX/UI and icon guidelines) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable --- Release Notes: - Fixed renaming a folder with a dot in its name selecting only the part before the dot. --------- Co-authored-by: Finn Evers <finn.evers@outlook.de>
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.
Objective
the last dot, treating the suffix as if it were a file extension.
Solution
ProjectPanel::rename_implcomputed the rename editor's initial selection withPath::file_stem().len()for every entry. For a directory such asmy.folder,file_stem()returnsmy, so onlymywas selected.the existing behavior (the last extension is left unselected for quick renames).
Testing
test_rename_folder_with_dot_selects_whole_nameinproject_panel_tests.rs.It fails before the change (folder selection ends at offset 2 of
my.folder) andpasses after (offset 9, the whole name); it also asserts a file still leaves the
last extension unselected.
cargo test -p project_panel— all 100 tests pass.cargo clippy -p project_panel --all-targets --all-features -- --deny warningsandcargo fmt -p project_panel -- --checkare clean.Self-Review Checklist:
Release Notes: