Merge pull request #18922 from Veykril/push-tmtzukrsnott
fix: Don't return inlay hints outside requested range
This commit is contained in:
commit
805598dac3
2 changed files with 27 additions and 23 deletions
|
|
@ -112,6 +112,9 @@ pub(crate) fn inlay_hints(
|
|||
}
|
||||
hints(event);
|
||||
}
|
||||
if let Some(range_limit) = range_limit {
|
||||
acc.retain(|hint| range_limit.contains_range(hint.range));
|
||||
}
|
||||
acc
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -392,36 +392,37 @@ fn main() {
|
|||
#[test]
|
||||
fn check_hint_range_limit() {
|
||||
let fixture = r#"
|
||||
//- minicore: fn, sized
|
||||
fn foo() -> impl Fn() { loop {} }
|
||||
fn foo1() -> impl Fn(f64) { loop {} }
|
||||
fn foo2() -> impl Fn(f64, f64) { loop {} }
|
||||
fn foo3() -> impl Fn(f64, f64) -> u32 { loop {} }
|
||||
fn foo4() -> &'static dyn Fn(f64, f64) -> u32 { loop {} }
|
||||
fn foo5() -> &'static dyn Fn(&'static dyn Fn(f64, f64) -> u32, f64) -> u32 { loop {} }
|
||||
fn foo6() -> impl Fn(f64, f64) -> u32 + Sized { loop {} }
|
||||
fn foo7() -> *const (impl Fn(f64, f64) -> u32 + Sized) { loop {} }
|
||||
//- minicore: fn, sized
|
||||
fn foo() -> impl Fn() { loop {} }
|
||||
fn foo1() -> impl Fn(f64) { loop {} }
|
||||
fn foo2() -> impl Fn(f64, f64) { loop {} }
|
||||
fn foo3() -> impl Fn(f64, f64) -> u32 { loop {} }
|
||||
fn foo4() -> &'static dyn Fn(f64, f64) -> u32 { loop {} }
|
||||
fn foo5() -> &'static dyn Fn(&'static dyn Fn(f64, f64) -> u32, f64) -> u32 { loop {} }
|
||||
fn foo6() -> impl Fn(f64, f64) -> u32 + Sized { loop {} }
|
||||
fn foo7() -> *const (impl Fn(f64, f64) -> u32 + Sized) { loop {} }
|
||||
|
||||
fn main() {
|
||||
let foo = foo();
|
||||
let foo = foo1();
|
||||
let foo = foo2();
|
||||
// ^^^ impl Fn(f64, f64)
|
||||
let foo = foo3();
|
||||
// ^^^ impl Fn(f64, f64) -> u32
|
||||
let foo = foo4();
|
||||
let foo = foo5();
|
||||
let foo = foo6();
|
||||
let foo = foo7();
|
||||
}
|
||||
"#;
|
||||
fn main() {
|
||||
let foo = foo();
|
||||
let foo = foo1();
|
||||
let foo = foo2();
|
||||
// ^^^ impl Fn(f64, f64)
|
||||
let foo = foo3();
|
||||
// ^^^ impl Fn(f64, f64) -> u32
|
||||
let foo = foo4();
|
||||
// ^^^ &dyn Fn(f64, f64) -> u32
|
||||
let foo = foo5();
|
||||
let foo = foo6();
|
||||
let foo = foo7();
|
||||
}
|
||||
"#;
|
||||
let (analysis, file_id) = fixture::file(fixture);
|
||||
let expected = extract_annotations(&analysis.file_text(file_id).unwrap());
|
||||
let inlay_hints = analysis
|
||||
.inlay_hints(
|
||||
&InlayHintsConfig { type_hints: true, ..DISABLED_CONFIG },
|
||||
file_id,
|
||||
Some(TextRange::new(TextSize::from(500), TextSize::from(600))),
|
||||
Some(TextRange::new(TextSize::from(491), TextSize::from(640))),
|
||||
)
|
||||
.unwrap();
|
||||
let actual =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue