Fix up the inlay_hint_cache proper (document the bug around inserting at inlay hint).
Co-authored-by: Antonio <antonio@zed.dev> Co-authored-by: Kirill <kirill@zed.dev>
This commit is contained in:
parent
dffe323e73
commit
001ce47a0c
1 changed files with 25 additions and 27 deletions
|
@ -2403,7 +2403,6 @@ pub mod tests {
|
||||||
|
|
||||||
#[gpui::test(iterations = 10)]
|
#[gpui::test(iterations = 10)]
|
||||||
async fn test_multiple_excerpts_large_multibuffer(cx: &mut gpui::TestAppContext) {
|
async fn test_multiple_excerpts_large_multibuffer(cx: &mut gpui::TestAppContext) {
|
||||||
// todo!() this test is flaky
|
|
||||||
init_test(cx, |settings| {
|
init_test(cx, |settings| {
|
||||||
settings.defaults.inlay_hints = Some(InlayHintSettings {
|
settings.defaults.inlay_hints = Some(InlayHintSettings {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
|
@ -2604,8 +2603,6 @@ pub mod tests {
|
||||||
"main hint #1".to_string(),
|
"main hint #1".to_string(),
|
||||||
"main hint #2".to_string(),
|
"main hint #2".to_string(),
|
||||||
"main hint #3".to_string(),
|
"main hint #3".to_string(),
|
||||||
// todo!() there used to be no these hints, but new gpui2 presumably scrolls a bit farther
|
|
||||||
// (or renders less?) note that tests below pass
|
|
||||||
"main hint #4".to_string(),
|
"main hint #4".to_string(),
|
||||||
"main hint #5".to_string(),
|
"main hint #5".to_string(),
|
||||||
];
|
];
|
||||||
|
@ -2710,37 +2707,38 @@ pub mod tests {
|
||||||
editor_edited.store(true, Ordering::Release);
|
editor_edited.store(true, Ordering::Release);
|
||||||
editor.update(cx, |editor, cx| {
|
editor.update(cx, |editor, cx| {
|
||||||
editor.change_selections(None, cx, |s| {
|
editor.change_selections(None, cx, |s| {
|
||||||
s.select_ranges([Point::new(56, 0)..Point::new(56, 0)])
|
// TODO if this gets set to hint boundary (e.g. 56) we sometimes get an extra cache version bump, why?
|
||||||
|
s.select_ranges([Point::new(57, 0)..Point::new(57, 0)])
|
||||||
});
|
});
|
||||||
editor.handle_input("++++more text++++", cx);
|
editor.handle_input("++++more text++++", cx);
|
||||||
});
|
});
|
||||||
cx.executor().run_until_parked();
|
cx.executor().run_until_parked();
|
||||||
editor.update(cx, |editor, cx| {
|
editor.update(cx, |editor, cx| {
|
||||||
let expected_hints = vec![
|
let expected_hints = vec![
|
||||||
"main hint(edited) #0".to_string(),
|
"main hint(edited) #0".to_string(),
|
||||||
"main hint(edited) #1".to_string(),
|
"main hint(edited) #1".to_string(),
|
||||||
"main hint(edited) #2".to_string(),
|
"main hint(edited) #2".to_string(),
|
||||||
"main hint(edited) #3".to_string(),
|
"main hint(edited) #3".to_string(),
|
||||||
"main hint(edited) #4".to_string(),
|
"main hint(edited) #4".to_string(),
|
||||||
"main hint(edited) #5".to_string(),
|
"main hint(edited) #5".to_string(),
|
||||||
"other hint(edited) #0".to_string(),
|
"other hint(edited) #0".to_string(),
|
||||||
"other hint(edited) #1".to_string(),
|
"other hint(edited) #1".to_string(),
|
||||||
];
|
];
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
expected_hints,
|
expected_hints,
|
||||||
cached_hint_labels(editor),
|
cached_hint_labels(editor),
|
||||||
"After multibuffer edit, editor gets scolled back to the last selection; \
|
"After multibuffer edit, editor gets scolled back to the last selection; \
|
||||||
all hints should be invalidated and requeried for all of its visible excerpts"
|
all hints should be invalidated and requeried for all of its visible excerpts"
|
||||||
);
|
);
|
||||||
assert_eq!(expected_hints, visible_hint_labels(editor, cx));
|
assert_eq!(expected_hints, visible_hint_labels(editor, cx));
|
||||||
|
|
||||||
let current_cache_version = editor.inlay_hint_cache().version;
|
let current_cache_version = editor.inlay_hint_cache().version;
|
||||||
let minimum_expected_version = last_scroll_update_version + expected_hints.len();
|
assert_eq!(
|
||||||
assert!(
|
current_cache_version,
|
||||||
current_cache_version >= minimum_expected_version,
|
last_scroll_update_version + expected_hints.len(),
|
||||||
"TODO: Something happens with multi-excerpt buffer when editing it: we query overly many inlay hints instead of just visible excerpts"
|
"We should have updated cache N times == N of new hints arrived (separately from each excerpt)"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue