diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs index 23d8852185..1982434663 100644 --- a/crates/ide/src/display/navigation_target.rs +++ b/crates/ide/src/display/navigation_target.rs @@ -85,12 +85,16 @@ impl NavigationTarget { let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default(); if let Some(src) = module.declaration_source(db) { let node = src.as_ref().map(|it| it.syntax()); - let frange = node.original_file_range(db); + let full_range = node.original_file_range(db); + let focus_range = src + .value + .name() + .map(|name| src.with_value(name.syntax()).original_file_range(db).range); let mut res = NavigationTarget::from_syntax( - frange.file_id, + full_range.file_id, name, - None, - frange.range, + focus_range, + full_range.range, SymbolKind::Module, ); res.docs = module.attrs(db).docs(); diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs index c91eb12833..e86ae2a188 100644 --- a/crates/ide/src/goto_definition.rs +++ b/crates/ide/src/goto_definition.rs @@ -131,7 +131,6 @@ pub(crate) fn reference_definition( #[cfg(test)] mod tests { use ide_db::base_db::FileRange; - use syntax::{TextRange, TextSize}; use crate::fixture; diff --git a/crates/ide/src/parent_module.rs b/crates/ide/src/parent_module.rs index e5515ef2c0..7b08bc27bf 100644 --- a/crates/ide/src/parent_module.rs +++ b/crates/ide/src/parent_module.rs @@ -81,8 +81,8 @@ mod tests { check( r#" //- /lib.rs - mod foo; -//^^^^^^^^ +mod foo; + //^^^ //- /foo.rs $0// empty @@ -96,8 +96,8 @@ $0// empty check( r#" //- /lib.rs - mod foo; -//^^^^^^^^ +mod foo; + //^^^ //- /foo.rs mod $0bar; @@ -115,7 +115,7 @@ mod $0bar; mod foo { mod bar { mod baz { $0 } - } //^^^^^^^^^^^^ + } //^^^ } "#, );