From f57ce369880f952c97e8a063b5f0fe4abe1d84a4 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 10 Dec 2020 14:16:34 +0100 Subject: Fix FileId computation in IncorrectCase fix --- crates/ide/src/diagnostics/fixes.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/ide/src/diagnostics/fixes.rs b/crates/ide/src/diagnostics/fixes.rs index 29c7a040b..a900d7bae 100644 --- a/crates/ide/src/diagnostics/fixes.rs +++ b/crates/ide/src/diagnostics/fixes.rs @@ -6,7 +6,7 @@ use hir::{ Diagnostic, IncorrectCase, MissingFields, MissingOkInTailExpr, NoSuchField, UnresolvedModule, }, - HasSource, HirDisplay, Semantics, VariantDef, + HasSource, HirDisplay, InFile, Semantics, VariantDef, }; use ide_db::base_db::{AnchoredPathBuf, FileId}; use ide_db::{ @@ -110,9 +110,9 @@ impl DiagnosticWithFix for IncorrectCase { let root = sema.db.parse_or_expand(self.file)?; let name_node = self.ident.to_node(&root); - let file_id = self.file.original_file(sema.db); - let offset = name_node.syntax().text_range().start(); - let file_position = FilePosition { file_id, offset }; + let name_node = InFile::new(self.file, name_node.syntax()); + let frange = name_node.original_file_range(sema.db); + let file_position = FilePosition { file_id: frange.file_id, offset: frange.range.start() }; let rename_changes = rename_with_semantics(sema, file_position, &self.suggested_text).ok()?; -- cgit v1.2.3