From 0b93e490a550693f4b65faf61d30c8ae14943cb2 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Thu, 10 Aug 2023 12:28:17 +0300 Subject: [PATCH] Improve toggle UI, fix inlays update speed --- crates/editor/src/editor.rs | 11 ++++++----- crates/zed/src/quick_action_bar.rs | 10 +++++----- styles/src/style_tree/workspace.ts | 1 + 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 3c6103cd908b2fd0d5ebc6bd8cafe3c1a54a5ea9..ef02cee3d03babc9a1279d2654a19da830ed53ce 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1240,7 +1240,7 @@ enum GotoDefinitionKind { #[derive(Debug, Clone)] enum InlayRefreshReason { - Toggled(bool), + Toggle(bool), SettingsChange(InlayHintSettings), NewLinesShown, BufferEdited(HashSet>), @@ -2673,11 +2673,10 @@ impl Editor { } pub fn toggle_inlays(&mut self, _: &ToggleInlays, cx: &mut ViewContext) { - self.inlay_hint_cache.enabled = !self.inlay_hint_cache.enabled; self.refresh_inlays( - InlayRefreshReason::Toggled(self.inlay_hint_cache.enabled), + InlayRefreshReason::Toggle(!self.inlay_hint_cache.enabled), cx, - ) + ); } pub fn inlays_enabled(&self) -> bool { @@ -2690,7 +2689,8 @@ impl Editor { } let (invalidate_cache, required_languages) = match reason { - InlayRefreshReason::Toggled(enabled) => { + InlayRefreshReason::Toggle(enabled) => { + self.inlay_hint_cache.enabled = enabled; if enabled { (InvalidationStrategy::RefreshRequested, None) } else { @@ -2805,6 +2805,7 @@ impl Editor { self.display_map.update(cx, |display_map, cx| { display_map.splice_inlays(to_remove, to_insert, cx); }); + cx.notify(); } fn trigger_on_type_formatting( diff --git a/crates/zed/src/quick_action_bar.rs b/crates/zed/src/quick_action_bar.rs index c133f5ece44bc238912cbc91817095d2863cf4d3..6157ca9c47bb63d35d02f50cf3dc70347887e324 100644 --- a/crates/zed/src/quick_action_bar.rs +++ b/crates/zed/src/quick_action_bar.rs @@ -45,10 +45,7 @@ impl View for QuickActionBar { 0, "icons/hamburger_15.svg", inlays_enabled, - ( - "Toggle inlays".to_string(), - Some(Box::new(editor::ToggleInlays)), - ), + ("Inlays".to_string(), Some(Box::new(editor::ToggleInlays))), cx, |this, cx| { if let Some(editor) = this.active_editor() { @@ -78,7 +75,8 @@ impl View for QuickActionBar { "icons/magnifying_glass_12.svg", search_bar_shown, ( - "Toggle buffer search".to_string(), + "Buffer search".to_string(), + // TODO kb no keybinding is shown for search + toggle inlays does not update icon color Some(Box::new(search_action.clone())), ), cx, @@ -132,6 +130,8 @@ fn render_quick_action_bar_button< .constrained() .with_width(style.button_width) .with_height(style.button_width) + .contained() + .with_style(style.container) }) .with_cursor_style(CursorStyle::PointingHand) .on_click(MouseButton::Left, move |_, pane, cx| on_click(pane, cx)) diff --git a/styles/src/style_tree/workspace.ts b/styles/src/style_tree/workspace.ts index 4d44166eb8075ab4aae39fdc033b19b76f8fa7dd..578dd23c6ecf30f3acef617fc6cf4140547980bf 100644 --- a/styles/src/style_tree/workspace.ts +++ b/styles/src/style_tree/workspace.ts @@ -151,6 +151,7 @@ export default function workspace(): any { }, }), toggleable_tool: toggleable_icon_button(theme, { + margin: { left: 8 }, active_color: "accent", }), padding: { left: 8, right: 8, top: 4, bottom: 4 },