Skip to content

project_panel: Select the whole folder name when renaming - #59390

Merged
MrSubidubi merged 2 commits into
zed-industries:mainfrom
IbrahimKhan12:fix/project-panel-folder-rename-selection
Jun 16, 2026
Merged

project_panel: Select the whole folder name when renaming#59390
MrSubidubi merged 2 commits into
zed-industries:mainfrom
IbrahimKhan12:fix/project-panel-folder-rename-selection

Conversation

@IbrahimKhan12

@IbrahimKhan12 IbrahimKhan12 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Objective

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:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • 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.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 15, 2026
@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Jun 15, 2026
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
IbrahimKhan12 force-pushed the fix/project-panel-folder-rename-selection branch from b7ce6c1 to 10bf8b2 Compare June 15, 2026 23:16
@IbrahimKhan12
IbrahimKhan12 marked this pull request as ready for review June 15, 2026 23:17
Comment thread crates/project_panel/src/project_panel.rs Outdated

@MrSubidubi MrSubidubi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix, thanks for this and congrats to your first contribution! 🎉

@MrSubidubi
MrSubidubi added this pull request to the merge queue Jun 16, 2026
Merged via the queue into zed-industries:main with commit c0f4059 Jun 16, 2026
32 checks passed
This was referenced Jun 18, 2026
@IbrahimKhan12
IbrahimKhan12 deleted the fix/project-panel-folder-rename-selection branch June 18, 2026 23:13
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Renaming folder doesn't highlight name after last dot

2 participants