From 708409e06d381269a21dedbd02fa86b30c5d4047 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 10 Aug 2023 14:51:38 +0300 Subject: [PATCH] Query hints on every scroll --- crates/editor/src/inlay_hint_cache.rs | 4 +++- crates/editor/src/scroll.rs | 6 ++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/editor/src/inlay_hint_cache.rs b/crates/editor/src/inlay_hint_cache.rs index 44fbbf163d..1dbef165fa 100644 --- a/crates/editor/src/inlay_hint_cache.rs +++ b/crates/editor/src/inlay_hint_cache.rs @@ -24,6 +24,7 @@ pub struct InlayHintCache { allowed_hint_kinds: HashSet>, version: usize, enabled: bool, + // TODO kb track them by excerpt range update_tasks: HashMap, } @@ -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(); diff --git a/crates/editor/src/scroll.rs b/crates/editor/src/scroll.rs index d595337428..1f3adaf477 100644 --- a/crates/editor/src/scroll.rs +++ b/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) -> Vector2F {