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.
This commit is contained in:
Ville Penttinen 2019-02-23 11:02:42 +02:00
parent 3d8a0982a1
commit 2a3abe2ce3
2 changed files with 126 additions and 4 deletions

View file

@ -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())