Skip to content

Commit d5c9de6

Browse files
committed
Don't filter equal nodes in reorder assists
1 parent b290cd5 commit d5c9de6

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

crates/ide_assists/src/handlers/reorder_fields.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,9 @@ fn replace<T: AstNode + PartialEq>(
8383
fields: impl Iterator<Item = T>,
8484
sorted_fields: impl IntoIterator<Item = T>,
8585
) {
86-
fields.zip(sorted_fields).filter(|(field, sorted)| field != sorted).for_each(
87-
|(field, sorted_field)| {
88-
ted::replace(field.syntax(), sorted_field.syntax().clone_for_update());
89-
},
90-
);
86+
fields.zip(sorted_fields).for_each(|(field, sorted_field)| {
87+
ted::replace(field.syntax(), sorted_field.syntax().clone_for_update())
88+
});
9189
}
9290

9391
fn compute_fields_ranks(path: &ast::Path, ctx: &AssistContext) -> Option<FxHashMap<String, usize>> {

crates/ide_assists/src/handlers/reorder_impl.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,9 @@ pub(crate) fn reorder_impl(acc: &mut Assists, ctx: &AssistContext) -> Option<()>
7979
"Sort methods",
8080
target,
8181
|builder| {
82-
for (old, new) in
83-
methods.into_iter().zip(sorted).filter(|(field, sorted)| field != sorted)
84-
{
85-
ted::replace(builder.make_ast_mut(old).syntax(), new.clone_for_update().syntax());
86-
}
82+
methods.into_iter().zip(sorted).for_each(|(old, new)| {
83+
ted::replace(builder.make_ast_mut(old).syntax(), new.clone_for_update().syntax())
84+
});
8785
},
8886
)
8987
}

0 commit comments

Comments
 (0)