From 385e05ee00197a7958fa7c14d94bbf25cb47a1cd Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 2 Dec 2024 18:32:07 +0200 Subject: [PATCH] zzz --- crates/editor/src/editor.rs | 1 + crates/editor/src/inlay_hint_cache.rs | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 02f01dbaec812..c7c2e95a2df0a 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -303,6 +303,7 @@ pub fn init(cx: &mut AppContext) { workspace::register_project_item::(cx); workspace::FollowableViewRegistry::register::(cx); workspace::register_serializable_item::(cx); + inlay_hint_cache::init(cx); cx.observe_new_views( |workspace: &mut Workspace, _cx: &mut ViewContext| { diff --git a/crates/editor/src/inlay_hint_cache.rs b/crates/editor/src/inlay_hint_cache.rs index e7c97cbf09c44..6b6245c62d730 100644 --- a/crates/editor/src/inlay_hint_cache.rs +++ b/crates/editor/src/inlay_hint_cache.rs @@ -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, bool>); + +impl gpui::Global for InlayHintToggle {} + +pub fn init(cx: &mut AppContext) { + cx.set_global(InlayHintToggle::default()); +} + pub struct InlayHintCache { hints: HashMap>>, allowed_hint_kinds: HashSet>, @@ -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)