Don't filter equal nodes in reorder assists

This commit is contained in:
Lukas Wirth 2021-04-22 00:54:31 +02:00
parent b290cd5782
commit d5c9de65c5
2 changed files with 6 additions and 10 deletions

View file

@ -83,11 +83,9 @@ fn replace<T: AstNode + PartialEq>(
fields: impl Iterator<Item = T>,
sorted_fields: impl IntoIterator<Item = T>,
) {
fields.zip(sorted_fields).filter(|(field, sorted)| field != sorted).for_each(
|(field, sorted_field)| {
ted::replace(field.syntax(), sorted_field.syntax().clone_for_update());
},
);
fields.zip(sorted_fields).for_each(|(field, sorted_field)| {
ted::replace(field.syntax(), sorted_field.syntax().clone_for_update())
});
}
fn compute_fields_ranks(path: &ast::Path, ctx: &AssistContext) -> Option<FxHashMap<String, usize>> {

View file

@ -79,11 +79,9 @@ pub(crate) fn reorder_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
"Sort methods",
target,
|builder| {
for (old, new) in
methods.into_iter().zip(sorted).filter(|(field, sorted)| field != sorted)
{
ted::replace(builder.make_ast_mut(old).syntax(), new.clone_for_update().syntax());
}
methods.into_iter().zip(sorted).for_each(|(old, new)| {
ted::replace(builder.make_ast_mut(old).syntax(), new.clone_for_update().syntax())
});
},
)
}