From d5c9de65c555235d7a27dc4617858b7a24be4935 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Thu, 22 Apr 2021 00:54:31 +0200 Subject: Don't filter equal nodes in reorder assists --- crates/ide_assists/src/handlers/reorder_fields.rs | 8 +++----- crates/ide_assists/src/handlers/reorder_impl.rs | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) (limited to 'crates') diff --git a/crates/ide_assists/src/handlers/reorder_fields.rs b/crates/ide_assists/src/handlers/reorder_fields.rs index 1a95135ca..e90bbdbcf 100644 --- a/crates/ide_assists/src/handlers/reorder_fields.rs +++ b/crates/ide_assists/src/handlers/reorder_fields.rs @@ -83,11 +83,9 @@ fn replace( fields: impl Iterator, sorted_fields: impl IntoIterator, ) { - 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> { diff --git a/crates/ide_assists/src/handlers/reorder_impl.rs b/crates/ide_assists/src/handlers/reorder_impl.rs index fd2897c4c..72d889248 100644 --- a/crates/ide_assists/src/handlers/reorder_impl.rs +++ b/crates/ide_assists/src/handlers/reorder_impl.rs @@ -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()) + }); }, ) } -- cgit v1.2.3