From 1d54c49271af29814d9b380edee824cb4493c454 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 9 Dec 2020 12:45:39 +0100 Subject: Fix MissingFields DiagnosticFix trigger range --- crates/ide/src/diagnostics/fixes.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'crates/ide/src/diagnostics/fixes.rs') diff --git a/crates/ide/src/diagnostics/fixes.rs b/crates/ide/src/diagnostics/fixes.rs index d275dd75b..24d08651e 100644 --- a/crates/ide/src/diagnostics/fixes.rs +++ b/crates/ide/src/diagnostics/fixes.rs @@ -68,7 +68,8 @@ impl DiagnosticWithFix for MissingFields { } let root = sema.db.parse_or_expand(self.file)?; - let old_field_list = self.field_list_parent.to_node(&root).record_expr_field_list()?; + let field_list_parent = self.field_list_parent.to_node(&root); + let old_field_list = field_list_parent.record_expr_field_list()?; let mut new_field_list = old_field_list.clone(); for f in self.missed_fields.iter() { let field = @@ -85,7 +86,7 @@ impl DiagnosticWithFix for MissingFields { Some(Fix::new( "Fill struct fields", SourceFileEdit { file_id: self.file.original_file(sema.db), edit }.into(), - sema.original_range(&old_field_list.syntax()).range, + sema.original_range(&field_list_parent.syntax()).range, )) } } -- cgit v1.2.3