From 2a3abe2ce3ebaa0411012cc1be6829c9cb6ea16f Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Sat, 23 Feb 2019 11:02:42 +0200 Subject: Fix goto def not working when cursor was over the name of a def We now allow goto_definition to return the named NavigationTarget if the cursor is on the name of a definition. --- crates/ra_ide_api/src/navigation_target.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'crates/ra_ide_api/src/navigation_target.rs') diff --git a/crates/ra_ide_api/src/navigation_target.rs b/crates/ra_ide_api/src/navigation_target.rs index fd001179a..e9240283e 100644 --- a/crates/ra_ide_api/src/navigation_target.rs +++ b/crates/ra_ide_api/src/navigation_target.rs @@ -198,7 +198,8 @@ impl NavigationTarget { buf } - fn from_named(file_id: FileId, node: &impl ast::NameOwner) -> NavigationTarget { + /// Allows `NavigationTarget` to be created from a `NameOwner` + pub(crate) fn from_named(file_id: FileId, node: &impl ast::NameOwner) -> NavigationTarget { let name = node.name().map(|it| it.text().clone()).unwrap_or_default(); let focus_range = node.name().map(|it| it.syntax().range()); NavigationTarget::from_syntax(file_id, name, focus_range, node.syntax()) -- cgit v1.2.3 From 7046b162756b0fa1b6e6e2223ffbfdf6f41ca6bc Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Sat, 23 Feb 2019 12:53:53 +0200 Subject: Fix NavigationTarget debug_render container_name output --- crates/ra_ide_api/src/navigation_target.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_ide_api/src/navigation_target.rs') diff --git a/crates/ra_ide_api/src/navigation_target.rs b/crates/ra_ide_api/src/navigation_target.rs index e9240283e..2c9ec970a 100644 --- a/crates/ra_ide_api/src/navigation_target.rs +++ b/crates/ra_ide_api/src/navigation_target.rs @@ -193,7 +193,7 @@ impl NavigationTarget { buf.push_str(&format!(" {:?}", focus_range)) } if let Some(container_name) = self.container_name() { - buf.push_str(&format!(" {:?}", container_name)) + buf.push_str(&format!(" {}", container_name)) } buf } -- cgit v1.2.3 From c565ec2d6e736c90b8c5a6b89795022d1cc1c1a3 Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Sat, 23 Feb 2019 13:05:45 +0200 Subject: Add name_range field to FileSymbol This contains the syntax range of the name itself, allowing NavigationTarget to properly set the focus_range. This should make it so that when using symbol based navigation, we should always focus on the name, instead of the full range. --- crates/ra_ide_api/src/navigation_target.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_ide_api/src/navigation_target.rs') diff --git a/crates/ra_ide_api/src/navigation_target.rs b/crates/ra_ide_api/src/navigation_target.rs index 2c9ec970a..ce5ae0363 100644 --- a/crates/ra_ide_api/src/navigation_target.rs +++ b/crates/ra_ide_api/src/navigation_target.rs @@ -67,7 +67,7 @@ impl NavigationTarget { name: symbol.name.clone(), kind: symbol.ptr.kind(), full_range: symbol.ptr.range(), - focus_range: None, + focus_range: symbol.name_range, container_name: symbol.container_name.clone(), } } -- cgit v1.2.3