Query hints when editors gets open and visible

This commit is contained in:
Kirill Bulatov
2023-06-29 22:25:50 +03:00
parent 11fee4ce42
commit acef5ff195
4 changed files with 107 additions and 77 deletions
-1
View File
@@ -1393,7 +1393,6 @@ impl Editor {
}
this.report_editor_event("open", None, cx);
this.refresh_inlays(InlayRefreshReason::ExcerptEdited, cx);
this
}
+1 -1
View File
@@ -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) {
+15 -3
View File
@@ -19,7 +19,8 @@ use crate::{
display_map::{DisplaySnapshot, ToDisplayPoint},
hover_popover::hide_hover,
persistence::DB,
Anchor, DisplayPoint, Editor, EditorMode, Event, MultiBufferSnapshot, ToPoint,
Anchor, DisplayPoint, Editor, EditorMode, Event, InlayRefreshReason, MultiBufferSnapshot,
ToPoint,
};
use self::{
@@ -293,8 +294,19 @@ impl Editor {
self.scroll_manager.visible_line_count
}
pub(crate) fn set_visible_line_count(&mut self, lines: f32) {
pub(crate) fn set_visible_line_count(&mut self, lines: f32, cx: &mut ViewContext<Self>) {
let opened_first_time = self.scroll_manager.visible_line_count.is_none();
self.scroll_manager.visible_line_count = Some(lines);
if opened_first_time {
cx.spawn(|editor, mut cx| async move {
editor
.update(&mut cx, |editor, cx| {
editor.refresh_inlays(InlayRefreshReason::NewLinesShown, cx)
})
.ok()
})
.detach()
}
}
pub fn set_scroll_position(&mut self, scroll_position: Vector2F, cx: &mut ViewContext<Self>) {
@@ -322,7 +334,7 @@ impl Editor {
);
if !self.is_singleton(cx) {
self.refresh_inlays(crate::InlayRefreshReason::NewLinesShown, cx);
self.refresh_inlays(InlayRefreshReason::NewLinesShown, cx);
}
}