From db619510015ad64f561016f47866ae398c528c77 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Fri, 24 Nov 2023 22:29:24 +0800 Subject: [PATCH] fix: stepwise renaming causes uncertain sorting order --- yazi-core/src/manager/commands/rename.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/yazi-core/src/manager/commands/rename.rs b/yazi-core/src/manager/commands/rename.rs index b89b47b3..55c522fa 100644 --- a/yazi-core/src/manager/commands/rename.rs +++ b/yazi-core/src/manager/commands/rename.rs @@ -1,4 +1,4 @@ -use std::{collections::BTreeSet, ffi::OsStr, io::{stdout, BufWriter, Write}, path::PathBuf}; +use std::{ffi::OsStr, io::{stdout, BufWriter, Write}, path::PathBuf}; use anyhow::{anyhow, bail, Result}; use tokio::{fs::{self, OpenOptions}, io::{stdin, AsyncReadExt, AsyncWriteExt}}; @@ -22,13 +22,9 @@ impl Manager { return Ok(()); } - let parent = old.parent_url().unwrap(); - emit!(Files(FilesOp::Deleting(parent, BTreeSet::from([old])))); - let file = File::from(new.clone()).await?; - emit!(Files(FilesOp::Creating(file.parent().unwrap(), file.into_map()))); - Self::_hover(Some(new)); - Ok(()) + emit!(Files(FilesOp::Replacing(file.parent().unwrap(), file.into_map()))); + Ok(Self::_hover(Some(new))) } pub fn rename(&self, opt: impl Into) -> bool {