Do not track editor ranges in InlayHintCache

This commit is contained in:
Kirill Bulatov 2023-06-19 16:48:58 +03:00
parent 70a45fc800
commit 3b9a2e3261
4 changed files with 163 additions and 365 deletions

View file

@ -18,7 +18,6 @@ use workspace::WorkspaceId;
use crate::{
display_map::{DisplaySnapshot, ToDisplayPoint},
hover_popover::hide_hover,
inlay_hint_cache::InlayRefreshReason,
persistence::DB,
Anchor, DisplayPoint, Editor, EditorMode, Event, MultiBufferSnapshot, ToPoint,
};
@ -177,7 +176,7 @@ impl ScrollManager {
autoscroll: bool,
workspace_id: Option<i64>,
cx: &mut ViewContext<Editor>,
) -> ScrollAnchor {
) {
let (new_anchor, top_row) = if scroll_position.y() <= 0. {
(
ScrollAnchor {
@ -206,7 +205,6 @@ impl ScrollManager {
};
self.set_anchor(new_anchor, top_row, local, autoscroll, workspace_id, cx);
new_anchor
}
fn set_anchor(
@ -295,12 +293,8 @@ impl Editor {
self.scroll_manager.visible_line_count
}
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();
pub(crate) fn set_visible_line_count(&mut self, lines: f32) {
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>) {
@ -318,7 +312,7 @@ impl Editor {
hide_hover(self, cx);
let workspace_id = self.workspace.as_ref().map(|workspace| workspace.1);
let scroll_anchor = self.scroll_manager.set_scroll_position(
self.scroll_manager.set_scroll_position(
scroll_position,
&map,
local,
@ -326,7 +320,6 @@ impl Editor {
workspace_id,
cx,
);
self.refresh_inlays(InlayRefreshReason::Scroll(scroll_anchor), cx);
}
pub fn scroll_position(&self, cx: &mut ViewContext<Self>) -> Vector2F {