From d912444cacb0f9079680c505b3bb075fbeb208be Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 26 Jan 2021 00:44:27 +0100 Subject: Shorten hir::TypeParam full_range in NavigationTarget --- crates/ide/src/display/navigation_target.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'crates/ide/src/display') diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs index f178dd744..23d885218 100644 --- a/crates/ide/src/display/navigation_target.rs +++ b/crates/ide/src/display/navigation_target.rs @@ -435,13 +435,16 @@ impl TryToNav for hir::TypeParam { fn try_to_nav(&self, db: &RootDatabase) -> Option { let src = self.source(db)?; let full_range = match &src.value { - Either::Left(it) => it.syntax().text_range(), + Either::Left(it) => it + .name() + .map_or_else(|| it.syntax().text_range(), |name| name.syntax().text_range()), Either::Right(it) => it.syntax().text_range(), }; let focus_range = match &src.value { - Either::Left(_) => None, - Either::Right(it) => it.name().map(|it| it.syntax().text_range()), - }; + Either::Left(it) => it.name(), + Either::Right(it) => it.name(), + } + .map(|it| it.syntax().text_range()); Some(NavigationTarget { file_id: src.file_id.original_file(db), name: self.name(db).to_string().into(), -- cgit v1.2.3