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:
Piotr Osiewicz 2023-12-05 14:10:10 +01:00
parent dffe323e73
commit 001ce47a0c

View file

@ -2403,7 +2403,6 @@ pub mod tests {
#[gpui::test(iterations = 10)]
async fn test_multiple_excerpts_large_multibuffer(cx: &mut gpui::TestAppContext) {
// todo!() this test is flaky
init_test(cx, |settings| {
settings.defaults.inlay_hints = Some(InlayHintSettings {
enabled: true,
@ -2604,8 +2603,6 @@ pub mod tests {
"main hint #1".to_string(),
"main hint #2".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 #5".to_string(),
];
@ -2710,7 +2707,8 @@ pub mod tests {
editor_edited.store(true, Ordering::Release);
editor.update(cx, |editor, cx| {
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);
});
@ -2735,10 +2733,10 @@ pub mod tests {
assert_eq!(expected_hints, visible_hint_labels(editor, cx));
let current_cache_version = editor.inlay_hint_cache().version;
let minimum_expected_version = last_scroll_update_version + expected_hints.len();
assert!(
current_cache_version >= minimum_expected_version,
"TODO: Something happens with multi-excerpt buffer when editing it: we query overly many inlay hints instead of just visible excerpts"
assert_eq!(
current_cache_version,
last_scroll_update_version + expected_hints.len(),
"We should have updated cache N times == N of new hints arrived (separately from each excerpt)"
);
});
}