Properly refresh hints on editor open
This commit is contained in:
parent
58343563ba
commit
7ac1885449
4 changed files with 18 additions and 7 deletions
|
@ -1385,7 +1385,6 @@ impl Editor {
|
|||
}
|
||||
|
||||
this.report_editor_event("open", None, cx);
|
||||
this.refresh_inlays(InlayRefreshReason::VisibleExcerptsChange, cx);
|
||||
this
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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>) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue