Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix up the inlay_hint_cache proper (document the bug around inserting at inlay hint).
Piotr Osiewicz001ce47a0c43
diff --git a/crates/editor2/src/inlay_hint_cache.rs b/crates/editor2/src/inlay_hint_cache.rsindex 18a061276e9..aab985ff903 100644--- a/crates/editor2/src/inlay_hint_cache.rs+++ b/crates/editor2/src/inlay_hint_cache.rs@@ -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 flakyinit_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,37 +2707,38 @@ 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);});cx.executor().run_until_parked();editor.update(cx, |editor, cx| {- let expected_hints = vec![- "main hint(edited) #0".to_string(),- "main hint(edited) #1".to_string(),- "main hint(edited) #2".to_string(),- "main hint(edited) #3".to_string(),- "main hint(edited) #4".to_string(),- "main hint(edited) #5".to_string(),- "other hint(edited) #0".to_string(),- "other hint(edited) #1".to_string(),- ];- assert_eq!(- expected_hints,- cached_hint_labels(editor),- "After multibuffer edit, editor gets scolled back to the last selection; \+ let expected_hints = vec![+ "main hint(edited) #0".to_string(),+ "main hint(edited) #1".to_string(),+ "main hint(edited) #2".to_string(),+ "main hint(edited) #3".to_string(),+ "main hint(edited) #4".to_string(),+ "main hint(edited) #5".to_string(),+ "other hint(edited) #0".to_string(),+ "other hint(edited) #1".to_string(),+ ];+ assert_eq!(+ expected_hints,+ cached_hint_labels(editor),+ "After multibuffer edit, editor gets scolled back to the last selection; \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 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"- );- });+ let current_cache_version = editor.inlay_hint_cache().version;+ 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)"+ );+ });}#[gpui::test]