diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-05-04 11:26:18 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-05-04 11:26:18 +0100 |
commit | 0ef4665d42ed7274ee847306722e2a53d2603bc9 (patch) | |
tree | 00af22ec878cd6bf0d25d0d247b3d09ef6c6bb2d | |
parent | 9134d888b1f0d901f3338684f65bcf7c8ec6d413 (diff) | |
parent | 710e430dbb9048c473d0e19e714cef9e279fac11 (diff) |
Merge #4292
4292: Fix focus range for TypeParam r=matklad a=matklad
closes #4274
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r-- | crates/ra_ide/src/display/navigation_target.rs | 10 | ||||
-rw-r--r-- | crates/ra_ide/src/goto_definition.rs | 10 |
2 files changed, 12 insertions, 8 deletions
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index 914a8b471..de35c6711 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs | |||
@@ -376,16 +376,20 @@ impl ToNav for hir::Local { | |||
376 | impl ToNav for hir::TypeParam { | 376 | impl ToNav for hir::TypeParam { |
377 | fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { | 377 | fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { |
378 | let src = self.source(db); | 378 | let src = self.source(db); |
379 | let range = match src.value { | 379 | let full_range = match &src.value { |
380 | Either::Left(it) => it.syntax().text_range(), | 380 | Either::Left(it) => it.syntax().text_range(), |
381 | Either::Right(it) => it.syntax().text_range(), | 381 | Either::Right(it) => it.syntax().text_range(), |
382 | }; | 382 | }; |
383 | let focus_range = match &src.value { | ||
384 | Either::Left(_) => None, | ||
385 | Either::Right(it) => it.name().map(|it| it.syntax().text_range()), | ||
386 | }; | ||
383 | NavigationTarget { | 387 | NavigationTarget { |
384 | file_id: src.file_id.original_file(db), | 388 | file_id: src.file_id.original_file(db), |
385 | name: self.name(db).to_string().into(), | 389 | name: self.name(db).to_string().into(), |
386 | kind: TYPE_PARAM, | 390 | kind: TYPE_PARAM, |
387 | full_range: range, | 391 | full_range, |
388 | focus_range: None, | 392 | focus_range, |
389 | container_name: None, | 393 | container_name: None, |
390 | description: None, | 394 | description: None, |
391 | docs: None, | 395 | docs: None, |
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index 1dfca819d..dbb4f38c7 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs | |||
@@ -754,14 +754,14 @@ mod tests { | |||
754 | #[test] | 754 | #[test] |
755 | fn goto_for_type_param() { | 755 | fn goto_for_type_param() { |
756 | check_goto( | 756 | check_goto( |
757 | " | 757 | r#" |
758 | //- /lib.rs | 758 | //- /lib.rs |
759 | struct Foo<T> { | 759 | struct Foo<T: Clone> { |
760 | t: <|>T, | 760 | t: <|>T, |
761 | } | 761 | } |
762 | ", | 762 | "#, |
763 | "T TYPE_PARAM FileId(1) 11..12", | 763 | "T TYPE_PARAM FileId(1) 11..19 11..12", |
764 | "T", | 764 | "T: Clone|T", |
765 | ); | 765 | ); |
766 | } | 766 | } |
767 | 767 | ||