This commit is contained in:
Kirill Bulatov 2024-12-02 18:32:07 +02:00 committed by Kirill Bulatov
parent 8ccc7b81c8
commit e568184dda
2 changed files with 13 additions and 3 deletions

View file

@ -303,6 +303,7 @@ pub fn init(cx: &mut AppContext) {
workspace::register_project_item::<Editor>(cx);
workspace::FollowableViewRegistry::register::<Editor>(cx);
workspace::register_serializable_item::<Editor>(cx);
inlay_hint_cache::init(cx);
cx.observe_new_views(
|workspace: &mut Workspace, _cx: &mut ViewContext<Workspace>| {

View file

@ -19,8 +19,8 @@ use crate::{
use anyhow::Context;
use clock::Global;
use futures::future;
use gpui::{AsyncWindowContext, Model, ModelContext, Task, ViewContext};
use language::{language_settings::InlayHintKind, Buffer, BufferSnapshot};
use gpui::{AppContext, AsyncWindowContext, Model, ModelContext, Task, ViewContext};
use language::{language_settings::InlayHintKind, Buffer, BufferSnapshot, LanguageName};
use parking_lot::RwLock;
use project::{InlayHint, ResolveState};
@ -31,6 +31,15 @@ use sum_tree::Bias;
use text::{BufferId, ToOffset, ToPoint};
use util::{post_inc, ResultExt};
#[derive(Default, Clone)]
pub struct InlayHintToggle(HashMap<LanguageName, bool>);
impl gpui::Global for InlayHintToggle {}
pub fn init(cx: &mut AppContext) {
cx.set_global(InlayHintToggle::default());
}
pub struct InlayHintCache {
hints: HashMap<ExcerptId, Arc<RwLock<CachedExcerptHints>>>,
allowed_hint_kinds: HashSet<Option<InlayHintKind>>,
@ -291,7 +300,7 @@ impl InlayHintCache {
self.invalidate_debounce = debounce_value(new_hint_settings.edit_debounce_ms);
self.append_debounce = debounce_value(new_hint_settings.scroll_debounce_ms);
let new_allowed_hint_kinds = new_hint_settings.enabled_inlay_hint_kinds();
match (self.enabled, new_hint_settings.enabled) {
match dbg!(self.enabled, new_hint_settings.enabled) {
(false, false) => {
self.allowed_hint_kinds = new_allowed_hint_kinds;
ControlFlow::Break(None)