mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: make result consistent & handle cyclic rename entries & add test
contains valid rename and cycle
This commit is contained in:
parent
b8341e23f9
commit
212829370f
1 changed files with 15 additions and 3 deletions
|
|
@ -142,9 +142,15 @@ impl Manager {
|
||||||
});
|
});
|
||||||
|
|
||||||
if has_no_incomes.is_empty() {
|
if has_no_incomes.is_empty() {
|
||||||
todo!("Consider cycle")
|
// Remaining rename set has cycle, so we cannot sort, just return them all
|
||||||
|
let mut remain = todos.drain().collect::<Vec<_>>();
|
||||||
|
remain.sort();
|
||||||
|
sorted.reverse();
|
||||||
|
sorted.extend(remain);
|
||||||
|
return sorted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
has_no_incomes.sort();
|
||||||
for old in has_no_incomes {
|
for old in has_no_incomes {
|
||||||
income_map.remove(&old);
|
income_map.remove(&old);
|
||||||
let Some(new) = todos.remove(&old) else { unreachable!("") };
|
let Some(new) = todos.remove(&old) else { unreachable!("") };
|
||||||
|
|
@ -189,8 +195,14 @@ mod tests {
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
cmp(
|
cmp(
|
||||||
&[("1", "2"), ("2", "1")],
|
&[("2", "1"), ("1", "2")],
|
||||||
&[("2", "1"), ("1", "2")]
|
&[("1", "2"), ("2", "1")]
|
||||||
|
);
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
|
cmp(
|
||||||
|
&[("3", "2"), ("2", "1"), ("1", "3"), ("a", "b"), ("b", "c")],
|
||||||
|
&[("b", "c"), ("a", "b"), ("1", "3"), ("2", "1"), ("3", "2")]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue