mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: improve handling of cases where num of filenames differs between new and old
This commit is contained in:
parent
c4304b8313
commit
6a22f123de
1 changed files with 4 additions and 2 deletions
|
|
@ -52,12 +52,14 @@ impl Mgr {
|
||||||
|
|
||||||
async fn bulk_rename_do(root: PathBuf, old: Vec<PathBuf>, new: Vec<PathBuf>) -> Result<()> {
|
async fn bulk_rename_do(root: PathBuf, old: Vec<PathBuf>, new: Vec<PathBuf>) -> Result<()> {
|
||||||
terminal_clear(TTY.writer())?;
|
terminal_clear(TTY.writer())?;
|
||||||
if old.len() != new.len() {
|
if old.len() > new.len() {
|
||||||
TTY.writer().write_all(b"Number of old and new differ, press ENTER to exit")?;
|
TTY.writer().write_all(b"Number of old is greater than new, press ENTER to exit")?;
|
||||||
TTY.reader().read_exact(&mut [0])?;
|
TTY.reader().read_exact(&mut [0])?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let new = if new.len() > old.len() { new.into_iter().take(old.len()).collect() } else { new };
|
||||||
|
|
||||||
let (old, new) = old.into_iter().zip(new).filter(|(o, n)| o != n).unzip();
|
let (old, new) = old.into_iter().zip(new).filter(|(o, n)| o != n).unzip();
|
||||||
let todo = Self::prioritized_paths(old, new);
|
let todo = Self::prioritized_paths(old, new);
|
||||||
if todo.is_empty() {
|
if todo.is_empty() {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue