Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Properly refresh hints on editor open
Kirill Bulatov7ac1885449de
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex dd4b4167a05..b834ac6aca6 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -1385,7 +1385,6 @@ impl Editor {}this.report_editor_event("open", None, cx);- this.refresh_inlays(InlayRefreshReason::VisibleExcerptsChange, cx);this}diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rsindex 6525e7fc222..7936ed76cb8 100644--- a/crates/editor/src/element.rs+++ b/crates/editor/src/element.rs@@ -1921,7 +1921,7 @@ impl Element<Editor> for EditorElement {let em_advance = style.text.em_advance(cx.font_cache());let overscroll = vec2f(em_width, 0.);let snapshot = {- editor.set_visible_line_count(size.y() / line_height);+ editor.set_visible_line_count(size.y() / line_height, cx);let editor_width = text_width - gutter_margin - overscroll.x() - em_width;let wrap_width = match editor.soft_wrap_mode(cx) {diff --git a/crates/editor/src/inlay_hint_cache.rs b/crates/editor/src/inlay_hint_cache.rsindex 72eb241e5a6..a89d6da4dfb 100644--- a/crates/editor/src/inlay_hint_cache.rs+++ b/crates/editor/src/inlay_hint_cache.rs@@ -331,18 +331,19 @@ impl InlayHintCache {.or_insert_with(|| {BufferHints::new(new_hints_per_buffer.buffer_version.clone())});- let mut shown_buffer_hints = currently_shown_hints- .remove(&new_buffer_id)- .unwrap_or_default();+if cached_buffer_hints.buffer_version.changed_since(&new_hints_per_buffer.buffer_version){+ currently_shown_hints.remove(&new_buffer_id);continue;} else {cached_buffer_hints.buffer_version = new_hints_per_buffer.buffer_version;}+ let shown_buffer_hints =+ currently_shown_hints.entry(new_buffer_id).or_default();for (new_excerpt_id, new_hints_per_excerpt) innew_hints_per_buffer.hints_per_excerpt{@@ -489,6 +490,13 @@ impl InlayHintCache {if shown_buffer_hints.is_empty() {currently_shown_hints.remove(&new_buffer_id);+ } else {+ to_remove.extend(+ shown_buffer_hints+ .iter()+ .flat_map(|(_, hints_by_excerpt)| hints_by_excerpt.iter())+ .map(|(_, hint_id)| *hint_id),+ );}}diff --git a/crates/editor/src/scroll.rs b/crates/editor/src/scroll.rsindex b5343359b58..62986b69368 100644--- a/crates/editor/src/scroll.rs+++ b/crates/editor/src/scroll.rs@@ -295,8 +295,12 @@ impl Editor {self.scroll_manager.visible_line_count}- pub(crate) fn set_visible_line_count(&mut self, lines: f32) {- self.scroll_manager.visible_line_count = Some(lines)+ pub(crate) fn set_visible_line_count(&mut self, lines: f32, cx: &mut ViewContext<Self>) {+ let had_no_visibles = self.scroll_manager.visible_line_count.is_none();+ self.scroll_manager.visible_line_count = Some(lines);+ if had_no_visibles {+ self.refresh_inlays(InlayRefreshReason::VisibleExcerptsChange, cx);+ }}pub fn set_scroll_position(&mut self, scroll_position: Vector2F, cx: &mut ViewContext<Self>) {