Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Repaint inlays icon on inlays cache disabling/enabling
Kirill Bulatov0f650acc23a8
diff --git a/crates/editor/src/inlay_hint_cache.rs b/crates/editor/src/inlay_hint_cache.rsindex 4327ff0d733..33855469711 100644--- a/crates/editor/src/inlay_hint_cache.rs+++ b/crates/editor/src/inlay_hint_cache.rs@@ -24,7 +24,7 @@ pub struct InlayHintCache {hints: HashMap<ExcerptId, Arc<RwLock<CachedExcerptHints>>>,allowed_hint_kinds: HashSet<Option<InlayHintKind>>,version: usize,- enabled: bool,+ pub(super) enabled: bool,update_tasks: HashMap<ExcerptId, TasksForRanges>,}diff --git a/crates/gpui/src/keymap_matcher/binding.rs b/crates/gpui/src/keymap_matcher/binding.rsindex 527052c85d3..f7296d50fbe 100644--- a/crates/gpui/src/keymap_matcher/binding.rs+++ b/crates/gpui/src/keymap_matcher/binding.rs@@ -88,8 +88,12 @@ impl Binding {action: &dyn Action,contexts: &[KeymapContext],) -> Option<SmallVec<[Keystroke; 2]>> {- if self.action.eq(action) && self.match_context(contexts) {- Some(self.keystrokes.clone())+ if self.action.eq(action) {+ if self.match_context(contexts) {+ Some(self.keystrokes.clone())+ } else {+ None+ }} else {None}diff --git a/crates/zed/src/quick_action_bar.rs b/crates/zed/src/quick_action_bar.rsindex 6157ca9c47b..245983dc49b 100644--- a/crates/zed/src/quick_action_bar.rs+++ b/crates/zed/src/quick_action_bar.rs@@ -2,7 +2,7 @@ use editor::Editor;use gpui::{elements::{Empty, Flex, MouseEventHandler, ParentElement, Svg},platform::{CursorStyle, MouseButton},- Action, AnyElement, Element, Entity, EventContext, View, ViewContext, ViewHandle,+ Action, AnyElement, Element, Entity, EventContext, Subscription, View, ViewContext, ViewHandle,};use search::{buffer_search, BufferSearchBar};@@ -11,6 +11,7 @@ use workspace::{item::ItemHandle, Pane, ToolbarItemLocation, ToolbarItemView};pub struct QuickActionBar {pane: ViewHandle<Pane>,active_item: Option<Box<dyn ItemHandle>>,+ _inlays_enabled_subscription: Option<Subscription>,}impl QuickActionBar {@@ -18,6 +19,7 @@ impl QuickActionBar {Self {pane,active_item: None,+ _inlays_enabled_subscription: None,}}@@ -76,7 +78,6 @@ impl View for QuickActionBar {search_bar_shown,("Buffer search".to_string(),- // TODO kb no keybinding is shown for search + toggle inlays does not update icon colorSome(Box::new(search_action.clone())),),cx,@@ -143,11 +144,25 @@ impl ToolbarItemView for QuickActionBar {fn set_active_pane_item(&mut self,active_pane_item: Option<&dyn ItemHandle>,- _: &mut ViewContext<Self>,+ cx: &mut ViewContext<Self>,) -> ToolbarItemLocation {match active_pane_item {Some(active_item) => {self.active_item = Some(active_item.boxed_clone());+ self._inlays_enabled_subscription.take();++ if let Some(editor) = active_item.downcast::<Editor>() {+ let mut inlays_enabled = editor.read(cx).inlays_enabled();+ self._inlays_enabled_subscription =+ Some(cx.observe(&editor, move |_, editor, cx| {+ let new_inlays_enabled = editor.read(cx).inlays_enabled();+ if inlays_enabled != new_inlays_enabled {+ inlays_enabled = new_inlays_enabled;+ cx.notify();+ }+ }));+ }+ToolbarItemLocation::PrimaryRight { flex: None }}None => {