mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
Disable inlay hint location links on vscode < 1.76
This commit is contained in:
parent
801a2231bf
commit
e1aa73ef40
9 changed files with 121 additions and 10 deletions
|
@ -194,7 +194,8 @@ mod tests {
|
|||
use crate::{fixture, inlay_hints::InlayHintsConfig};
|
||||
|
||||
use crate::inlay_hints::tests::{
|
||||
check, check_expect, check_with_config, DISABLED_CONFIG, TEST_CONFIG,
|
||||
check, check_expect, check_with_config, DISABLED_CONFIG, DISABLED_CONFIG_WITH_LINKS,
|
||||
TEST_CONFIG,
|
||||
};
|
||||
use crate::ClosureReturnTypeHints;
|
||||
|
||||
|
@ -290,7 +291,7 @@ fn main() {
|
|||
fn iterator_hint_regression_issue_12674() {
|
||||
// Ensure we don't crash while solving the projection type of iterators.
|
||||
check_expect(
|
||||
InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
|
||||
InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG_WITH_LINKS },
|
||||
r#"
|
||||
//- minicore: iterators
|
||||
struct S<T>(T);
|
||||
|
|
|
@ -74,7 +74,10 @@ mod tests {
|
|||
use expect_test::expect;
|
||||
|
||||
use crate::{
|
||||
inlay_hints::tests::{check_expect, check_with_config, DISABLED_CONFIG, TEST_CONFIG},
|
||||
inlay_hints::tests::{
|
||||
check_expect, check_with_config, DISABLED_CONFIG, DISABLED_CONFIG_WITH_LINKS,
|
||||
TEST_CONFIG,
|
||||
},
|
||||
InlayHintsConfig,
|
||||
};
|
||||
|
||||
|
@ -86,7 +89,11 @@ mod tests {
|
|||
#[test]
|
||||
fn chaining_hints_ignore_comments() {
|
||||
check_expect(
|
||||
InlayHintsConfig { type_hints: false, chaining_hints: true, ..DISABLED_CONFIG },
|
||||
InlayHintsConfig {
|
||||
type_hints: false,
|
||||
chaining_hints: true,
|
||||
..DISABLED_CONFIG_WITH_LINKS
|
||||
},
|
||||
r#"
|
||||
struct A(B);
|
||||
impl A { fn into_b(self) -> B { self.0 } }
|
||||
|
@ -179,10 +186,69 @@ fn main() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn struct_access_chaining_hints() {
|
||||
fn disabled_location_links() {
|
||||
check_expect(
|
||||
InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
|
||||
r#"
|
||||
struct A { pub b: B }
|
||||
struct B { pub c: C }
|
||||
struct C(pub bool);
|
||||
struct D;
|
||||
|
||||
impl D {
|
||||
fn foo(&self) -> i32 { 42 }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = A { b: B { c: C(true) } }
|
||||
.b
|
||||
.c
|
||||
.0;
|
||||
let x = D
|
||||
.foo();
|
||||
}"#,
|
||||
expect![[r#"
|
||||
[
|
||||
InlayHint {
|
||||
range: 143..190,
|
||||
kind: ChainingHint,
|
||||
label: [
|
||||
"C",
|
||||
],
|
||||
tooltip: Some(
|
||||
HoverRanged(
|
||||
FileId(
|
||||
0,
|
||||
),
|
||||
143..190,
|
||||
),
|
||||
),
|
||||
},
|
||||
InlayHint {
|
||||
range: 143..179,
|
||||
kind: ChainingHint,
|
||||
label: [
|
||||
"B",
|
||||
],
|
||||
tooltip: Some(
|
||||
HoverRanged(
|
||||
FileId(
|
||||
0,
|
||||
),
|
||||
143..179,
|
||||
),
|
||||
),
|
||||
},
|
||||
]
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn struct_access_chaining_hints() {
|
||||
check_expect(
|
||||
InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG_WITH_LINKS },
|
||||
r#"
|
||||
struct A { pub b: B }
|
||||
struct B { pub c: C }
|
||||
struct C(pub bool);
|
||||
|
@ -264,7 +330,7 @@ fn main() {
|
|||
#[test]
|
||||
fn generic_chaining_hints() {
|
||||
check_expect(
|
||||
InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
|
||||
InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG_WITH_LINKS },
|
||||
r#"
|
||||
struct A<T>(T);
|
||||
struct B<T>(T);
|
||||
|
@ -372,7 +438,7 @@ fn main() {
|
|||
#[test]
|
||||
fn shorten_iterator_chaining_hints() {
|
||||
check_expect(
|
||||
InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG },
|
||||
InlayHintsConfig { chaining_hints: true, ..DISABLED_CONFIG_WITH_LINKS },
|
||||
r#"
|
||||
//- minicore: iterators
|
||||
use core::iter;
|
||||
|
|
|
@ -109,7 +109,10 @@ pub(super) fn hints(
|
|||
return None;
|
||||
}
|
||||
|
||||
let linked_location = name_range.map(|range| FileRange { file_id, range });
|
||||
let linked_location = config
|
||||
.location_links
|
||||
.then(|| name_range.map(|range| FileRange { file_id, range }))
|
||||
.flatten();
|
||||
acc.push(InlayHint {
|
||||
range: closing_token.text_range(),
|
||||
kind: InlayKind::ClosingBraceHint,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue