Query hints when editors gets open and visible

This commit is contained in:
Kirill Bulatov 2023-06-25 01:32:45 +03:00
parent 11fee4ce42
commit acef5ff195
4 changed files with 107 additions and 77 deletions

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);
}
}