Improve delete prompt in project browser

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2022-05-05 15:49:40 +02:00
parent 6021ab12c9
commit 2e9bdfbeac

View file

@ -464,7 +464,14 @@ impl ProjectPanel {
fn delete(&mut self, _: &Delete, cx: &mut ViewContext<Self>) -> Option<Task<Result<()>>> {
let Selection { entry_id, .. } = self.selection?;
let mut answer = cx.prompt(PromptLevel::Info, "Delete?", &["Delete", "Cancel"]);
let path = self.project.read(cx).path_for_entry(entry_id, cx)?.path;
let file_name = path.file_name()?;
let mut answer = cx.prompt(
PromptLevel::Info,
&format!("Delete {file_name:?}?"),
&["Delete", "Cancel"],
);
Some(cx.spawn(|this, mut cx| async move {
if answer.next().await != Some(0) {
return Ok(());