diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index dd4b4167a0577ee5e439f89ab7a0d3527a8a8b27..b834ac6aca64ff66dc3091e3594efcb63cc22a82 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.rs index 6525e7fc222843fdfa04a94317f4a2a95f6dadcf..7936ed76cb85da078e61493b812c33d83a9a72b4 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1921,7 +1921,7 @@ impl Element 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.rs index 72eb241e5a63581c3a8b4438a86954dc9c5ede82..a89d6da4dfbc88f22901c4c5048c884f230d6de8 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) in new_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.rs index b5343359b58fe7c346a0c35cb48d09460aaba560..62986b69368c5bce40844ba4543dac17dced6f63 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) { + 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) {