Skip to content

Commit

Permalink
chore: remove copy file name actions from project panel's menu
Browse files Browse the repository at this point in the history
  • Loading branch information
ankddev committed Jan 24, 2025
1 parent f9d91f2 commit 99fe3dd
Showing 1 changed file with 1 addition and 45 deletions.
46 changes: 1 addition & 45 deletions crates/project_panel/src/project_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ actions!(
Copy,
CopyPath,
CopyRelativePath,
CopyFileName,
CopyFileNameWithoutExtension,
Duplicate,
RevealInFileManager,
RemoveFromProject,
Expand Down Expand Up @@ -672,7 +670,7 @@ impl ProjectPanel {
.action("Cut", Box::new(Cut))
.action("Copy", Box::new(Copy))
.action("Duplicate", Box::new(Duplicate))
// TODO: Paste should always be visible, cbut disabled when clipboard is empty
// TODO: Paste should always be visible, but disabled when clipboard is empty
.map(|menu| {
if self.clipboard.as_ref().is_some() {
menu.action("Paste", Box::new(Paste))
Expand All @@ -683,8 +681,6 @@ impl ProjectPanel {
.separator()
.action("Copy Path", Box::new(CopyPath))
.action("Copy Relative Path", Box::new(CopyRelativePath))
.action("Copy File Name without Extension", Box::new(CopyFileName))
.action("Copy File Name", Box::new(CopyFileNameWithoutExtension))
.separator()
.action("Rename", Box::new(Rename))
.when(!is_root & !is_remote, |menu| {
Expand Down Expand Up @@ -1991,44 +1987,6 @@ impl ProjectPanel {
}
}

fn copy_file_name_without_extension(
&mut self,
_: &CopyFileNameWithoutExtension,
cx: &mut ViewContext<Self>,
) {
let file_names = {
let project = self.project.read(cx);
self.marked_entries()
.into_iter()
.filter_map(|entry| {
let path = project.path_for_entry(entry.entry_id, cx)?.path;
path.file_stem()
.map(|name| name.to_string_lossy().to_string())
})
.collect::<Vec<_>>()
};
if !file_names.is_empty() {
cx.write_to_clipboard(ClipboardItem::new_string(file_names.join("\n")));
}
}

fn copy_file_name(&mut self, _: &CopyFileName, cx: &mut ViewContext<Self>) {
let file_names = {
let project = self.project.read(cx);
self.marked_entries()
.into_iter()
.filter_map(|entry| {
let path = project.path_for_entry(entry.entry_id, cx)?.path;
path.file_name()
.map(|name| name.to_string_lossy().to_string())
})
.collect::<Vec<_>>()
};
if !file_names.is_empty() {
cx.write_to_clipboard(ClipboardItem::new_string(file_names.join("\n")));
}
}

fn reveal_in_finder(&mut self, _: &RevealInFileManager, cx: &mut ViewContext<Self>) {
if let Some((worktree, entry)) = self.selected_sub_entry(cx) {
cx.reveal_path(&worktree.read(cx).abs_path().join(&entry.path));
Expand Down Expand Up @@ -4098,8 +4056,6 @@ impl Render for ProjectPanel {
.on_action(cx.listener(Self::cancel))
.on_action(cx.listener(Self::copy_path))
.on_action(cx.listener(Self::copy_relative_path))
.on_action(cx.listener(Self::copy_file_name))
.on_action(cx.listener(Self::copy_file_name_without_extension))
.on_action(cx.listener(Self::new_search_in_directory))
.on_action(cx.listener(Self::unfold_directory))
.on_action(cx.listener(Self::fold_directory))
Expand Down

0 comments on commit 99fe3dd

Please sign in to comment.