Query hints on every scroll

Kirill Bulatov created

Change summary

crates/editor/src/inlay_hint_cache.rs | 4 +++-
crates/editor/src/scroll.rs           | 6 ++----
2 files changed, 5 insertions(+), 5 deletions(-)

Detailed changes

crates/editor/src/inlay_hint_cache.rs 🔗

@@ -24,6 +24,7 @@ pub struct InlayHintCache {
     allowed_hint_kinds: HashSet<Option<InlayHintKind>>,
     version: usize,
     enabled: bool,
+    // TODO kb track them by excerpt range
     update_tasks: HashMap<ExcerptId, UpdateTask>,
 }
 
@@ -100,6 +101,7 @@ impl InvalidationStrategy {
 }
 
 impl ExcerptQuery {
+    // TODO kb query only visible + one visible below and above
     fn hints_fetch_ranges(&self, buffer: &BufferSnapshot) -> HintFetchRanges {
         let visible_range =
             self.dimensions.excerpt_visible_range_start..self.dimensions.excerpt_visible_range_end;
@@ -168,7 +170,6 @@ impl InlayHintCache {
                     );
                     if new_splice.is_some() {
                         self.version += 1;
-                        self.update_tasks.clear();
                         self.allowed_hint_kinds = new_allowed_hint_kinds;
                     }
                     ControlFlow::Break(new_splice)
@@ -464,6 +465,7 @@ fn spawn_new_update_tasks(
                     cx,
                 )
             };
+            // TODO kb need to add to update tasks + ensure RefreshRequested cleans other ranges
             match editor.inlay_hint_cache.update_tasks.entry(excerpt_id) {
                 hash_map::Entry::Occupied(mut o) => {
                     let update_task = o.get_mut();

crates/editor/src/scroll.rs 🔗

@@ -13,7 +13,7 @@ use gpui::{
 };
 use language::{Bias, Point};
 use util::ResultExt;
-use workspace::{item::Item, WorkspaceId};
+use workspace::WorkspaceId;
 
 use crate::{
     display_map::{DisplaySnapshot, ToDisplayPoint},
@@ -333,9 +333,7 @@ impl Editor {
             cx,
         );
 
-        if !self.is_singleton(cx) {
-            self.refresh_inlays(InlayRefreshReason::NewLinesShown, cx);
-        }
+        self.refresh_inlays(InlayRefreshReason::NewLinesShown, cx);
     }
 
     pub fn scroll_position(&self, cx: &mut ViewContext<Self>) -> Vector2F {