From ae4404f148b6b8e9dab4f1d9dd9366bc135c37a7 Mon Sep 17 00:00:00 2001 From: Om Chillure Date: Wed, 8 Apr 2026 21:53:43 +0530 Subject: [PATCH] project_panel: Fix duplicating a file only selects the copy suffix (#53146) Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [ ] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes #53116 Video [Screencast from 2026-04-04 19-14-55.webm](https://github.com/user-attachments/assets/d17945d6-b17c-435d-8155-648cd7ba574b) Release Notes: - Fixed: File duplication rename now selects the entire filename stem instead of just the " copy" suffix, allowing users to type a new name without manually clearing text --------- Co-authored-by: Smit Barmase --- crates/project_panel/src/project_panel.rs | 2 +- crates/project_panel/src/project_panel_tests.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index afb0d811fa378185f991ffbeb40a5d302ce565a6..3d10903eaa7881a75199eb6b1f981479659498f4 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -3040,7 +3040,7 @@ impl ProjectPanel { new_path.push(RelPath::unix(&new_file_name).unwrap()); - disambiguation_range = Some(file_name_len..(file_name_len + disambiguation_len)); + disambiguation_range = Some(0..(file_name_len + disambiguation_len)); ix += 1; } } diff --git a/crates/project_panel/src/project_panel_tests.rs b/crates/project_panel/src/project_panel_tests.rs index 603cfd892a218d866383f485d058296ad179da05..a49b32a694620d4313d4496390d21d85839e4230 100644 --- a/crates/project_panel/src/project_panel_tests.rs +++ b/crates/project_panel/src/project_panel_tests.rs @@ -1254,8 +1254,8 @@ async fn test_copy_paste(cx: &mut gpui::TestAppContext) { let file_name_selection = &file_name_selections[0]; assert_eq!( file_name_selection.start, - MultiBufferOffset("one".len()), - "Should select the file name disambiguation after the original file name" + MultiBufferOffset(0), + "Should select from the beginning of the filename" ); assert_eq!( file_name_selection.end,