fix: delete path, not confirmation e.g. `y`

pull/12902/head
Nikita Revenco 2025-02-18 12:38:11 +00:00
parent 6a558be7b3
commit b6bbd4f18a
1 changed files with 3 additions and 4 deletions

View File

@ -508,14 +508,13 @@ pub fn file_explorer(root: PathBuf, editor: &Editor) -> Result<FileExplorer, std
cx,
path,
|_| "".to_string(),
|_, _, to_delete_str| {
let to_delete = helix_stdx::path::expand_tilde(PathBuf::from(to_delete_str));
if to_delete_str == "y" {
|_, to_delete, confirmation| {
if confirmation == "y" {
if !to_delete.exists() {
return Some(Err(format!("Path {} does not exist", to_delete.display())))
};
if to_delete_str.ends_with(std::path::MAIN_SEPARATOR) {
if confirmation.ends_with(std::path::MAIN_SEPARATOR) {
if let Err(err) = fs::remove_dir_all(&to_delete).map_err(
|err| format!(
"Unable to delete directory {}: {err}", to_delete.display()