Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
ui: Follow-up to ui crate teardown (#52747)
Piotr Osiewicz1b9f3833f00f
diff --git a/Cargo.lock b/Cargo.lockindex 2c2b9b3f587..b2955988941 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -18781,7 +18781,6 @@ dependencies = ["menu","schemars","serde",- "settings","smallvec","story","strum 0.27.2",diff --git a/crates/csv_preview/src/csv_preview.rs b/crates/csv_preview/src/csv_preview.rsindex f056f5a1222..b0b6ad41867 100644--- a/crates/csv_preview/src/csv_preview.rs+++ b/crates/csv_preview/src/csv_preview.rs@@ -122,8 +122,9 @@ impl CsvPreviewView {fn new(editor: &Entity<Editor>, cx: &mut Context<Workspace>) -> Entity<Self> {let contents = TableLikeContent::default();let table_interaction_state = cx.new(|cx| {- TableInteractionState::new(cx)- .with_custom_scrollbar(ui::Scrollbars::for_settings::<editor::EditorSettings>())+ TableInteractionState::new(cx).with_custom_scrollbar(ui::Scrollbars::for_settings::<+ editor::EditorSettingsScrollbarProxy,+ >())});cx.new(|cx| {diff --git a/crates/editor/src/code_context_menus.rs b/crates/editor/src/code_context_menus.rsindex e1ea2822168..3fc6080b4da 100644--- a/crates/editor/src/code_context_menus.rs+++ b/crates/editor/src/code_context_menus.rs@@ -287,14 +287,9 @@ impl Drop for CompletionsMenu {}}+#[derive(Default)]struct CompletionMenuScrollBarSetting;-impl ui::scrollbars::GlobalSetting for CompletionMenuScrollBarSetting {- fn get_value(_cx: &App) -> &Self {- &Self- }-}-impl ui::scrollbars::ScrollbarVisibility for CompletionMenuScrollBarSetting {fn visibility(&self, cx: &App) -> ui::scrollbars::ShowScrollbar {EditorSettings::get_global(cx).completion_menu_scrollbardiff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 2f9af1bf233..6d9ee235f01 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -61,8 +61,8 @@ pub use display_map::{pub use edit_prediction_types::Direction;pub use editor_settings::{CompletionDetailAlignment, CurrentLineHighlight, DiffViewStyle, DocumentColorsRenderMode,- EditorSettings, HideMouseMode, ScrollBeyondLastLine, ScrollbarAxes, SearchSettings,- ShowMinimap,+ EditorSettings, EditorSettingsScrollbarProxy, HideMouseMode, ScrollBeyondLastLine,+ ScrollbarAxes, SearchSettings, ShowMinimap, ui_scrollbar_settings_from_raw,};pub use element::{CursorLayout, EditorElement, HighlightedRange, HighlightedRangeLine, PointForPosition,diff --git a/crates/editor/src/editor_settings.rs b/crates/editor/src/editor_settings.rsindex 98283f04585..fbb2ac703bf 100644--- a/crates/editor/src/editor_settings.rs+++ b/crates/editor/src/editor_settings.rs@@ -10,7 +10,7 @@ pub use settings::{ScrollbarDiagnostics, SeedQuerySetting, ShowMinimap, SnippetSortOrder,};use settings::{RegisterSetting, RelativeLineNumbers, Settings};-use ui::scrollbars::{ScrollbarVisibility, ShowScrollbar};+use ui::scrollbars::ShowScrollbar;/// Imports from the VSCode settings at/// https://code.visualstudio.com/docs/reference/default-settings@@ -183,12 +183,6 @@ impl EditorSettings {}}-impl ScrollbarVisibility for EditorSettings {- fn visibility(&self, _cx: &App) -> ShowScrollbar {- self.scrollbar.show- }-}-impl Settings for EditorSettings {fn from_settings(content: &settings::SettingsContent) -> Self {let editor = content.editor.clone();@@ -217,7 +211,7 @@ impl Settings for EditorSettings {code_actions: toolbar.code_actions.unwrap(),},scrollbar: Scrollbar {- show: scrollbar.show.map(Into::into).unwrap(),+ show: scrollbar.show.map(ui_scrollbar_settings_from_raw).unwrap(),git_diff: scrollbar.git_diff.unwrap()&& content.git@@ -294,9 +288,32 @@ impl Settings for EditorSettings {},lsp_document_colors: editor.lsp_document_colors.unwrap(),minimum_contrast_for_highlights: editor.minimum_contrast_for_highlights.unwrap().0,- completion_menu_scrollbar: editor.completion_menu_scrollbar.map(Into::into).unwrap(),+ completion_menu_scrollbar: editor+ .completion_menu_scrollbar+ .map(ui_scrollbar_settings_from_raw)+ .unwrap(),completion_detail_alignment: editor.completion_detail_alignment.unwrap(),diff_view_style: editor.diff_view_style.unwrap(),}}}++#[derive(Default)]+pub struct EditorSettingsScrollbarProxy;++impl ui::scrollbars::ScrollbarVisibility for EditorSettingsScrollbarProxy {+ fn visibility(&self, cx: &App) -> ShowScrollbar {+ EditorSettings::get_global(cx).scrollbar.show+ }+}++pub fn ui_scrollbar_settings_from_raw(+ value: settings::ShowScrollbar,+) -> ui::scrollbars::ShowScrollbar {+ match value {+ settings::ShowScrollbar::Auto => ShowScrollbar::Auto,+ settings::ShowScrollbar::System => ShowScrollbar::System,+ settings::ShowScrollbar::Always => ShowScrollbar::Always,+ settings::ShowScrollbar::Never => ShowScrollbar::Never,+ }+}diff --git a/crates/editor/src/hover_popover.rs b/crates/editor/src/hover_popover.rsindex 791f0d67a14..9b127a8f1bc 100644--- a/crates/editor/src/hover_popover.rs+++ b/crates/editor/src/hover_popover.rs@@ -2,6 +2,7 @@ use crate::{ActiveDiagnostic, Anchor, AnchorRangeExt, DisplayPoint, DisplayRow, Editor, EditorSettings,EditorSnapshot, GlobalDiagnosticRenderer, HighlightKey, Hover,display_map::{InlayOffset, ToDisplayPoint, is_invisible},+ editor_settings::EditorSettingsScrollbarProxy,hover_links::{InlayHighlight, RangeInEditor},movement::TextLayoutDetails,scroll::ScrollAmount,@@ -1048,7 +1049,7 @@ impl InfoPopover {),).custom_scrollbars(- Scrollbars::for_settings::<EditorSettings>()+ Scrollbars::for_settings::<EditorSettingsScrollbarProxy>().tracked_scroll_handle(&self.scroll_handle),window,cx,@@ -1176,7 +1177,7 @@ impl DiagnosticPopover {CopyButton::new("copy-diagnostic", message).tooltip_label("Copy Diagnostic")})).custom_scrollbars(- Scrollbars::for_settings::<EditorSettings>()+ Scrollbars::for_settings::<EditorSettingsScrollbarProxy>().tracked_scroll_handle(&self.scroll_handle),window,cx,diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rsindex 00058ee82bb..d8ef930cb25 100644--- a/crates/git_ui/src/git_panel.rs+++ b/crates/git_ui/src/git_panel.rs@@ -2,6 +2,7 @@ use crate::askpass_modal::AskPassModal;use crate::commit_modal::CommitModal;use crate::commit_tooltip::CommitTooltip;use crate::commit_view::CommitView;+use crate::git_panel_settings::GitPanelScrollbarAccessor;use crate::project_diff::{self, BranchDiff, Diff, ProjectDiff};use crate::remote_output::{self, RemoteAction, SuccessMessage};use crate::{branch_picker, picker_prompt, render_remote_button};@@ -4885,7 +4886,7 @@ impl GitPanel {}),).custom_scrollbars(- Scrollbars::for_settings::<GitPanelSettings>()+ Scrollbars::for_settings::<GitPanelScrollbarAccessor>().tracked_scroll_handle(&self.scroll_handle).with_track_along(ScrollAxes::Horizontal,diff --git a/crates/git_ui/src/git_panel_settings.rs b/crates/git_ui/src/git_panel_settings.rsindex 16a1113b60a..9ccbced249d 100644--- a/crates/git_ui/src/git_panel_settings.rs+++ b/crates/git_ui/src/git_panel_settings.rs@@ -1,4 +1,4 @@-use editor::EditorSettings;+use editor::{EditorSettings, ui_scrollbar_settings_from_raw};use gpui::Pixels;use schemars::JsonSchema;use serde::{Deserialize, Serialize};@@ -32,7 +32,10 @@ pub struct GitPanelSettings {pub starts_open: bool,}-impl ScrollbarVisibility for GitPanelSettings {+#[derive(Default)]+pub(crate) struct GitPanelScrollbarAccessor;++impl ScrollbarVisibility for GitPanelScrollbarAccessor {fn visibility(&self, cx: &ui::App) -> ShowScrollbar {// TODO: This PR should have defined Editor's `scrollbar.axis`// as an Option<ScrollbarAxis>, not a ScrollbarAxes as it would allow you to@@ -42,7 +45,8 @@ impl ScrollbarVisibility for GitPanelSettings {// so we can show each axis based on the settings.//// We should fix this. PR: https://github.com/zed-industries/zed/pull/19495- self.scrollbar+ GitPanelSettings::get_global(cx)+ .scrollbar.show.unwrap_or_else(|| EditorSettings::get_global(cx).scrollbar.show)}@@ -59,7 +63,11 @@ impl Settings for GitPanelSettings {file_icons: git_panel.file_icons.unwrap(),folder_icons: git_panel.folder_icons.unwrap(),scrollbar: ScrollbarSettings {- show: git_panel.scrollbar.unwrap().show.map(Into::into),+ show: git_panel+ .scrollbar+ .unwrap()+ .show+ .map(ui_scrollbar_settings_from_raw),},fallback_branch_name: git_panel.fallback_branch_name.unwrap(),sort_by_path: git_panel.sort_by_path.unwrap(),diff --git a/crates/keymap_editor/src/keymap_editor.rs b/crates/keymap_editor/src/keymap_editor.rsindex bc92763a770..6a02289353f 100644--- a/crates/keymap_editor/src/keymap_editor.rs+++ b/crates/keymap_editor/src/keymap_editor.rs@@ -542,8 +542,9 @@ impl KeymapEditor {let _keymap_subscription =cx.observe_global_in::<KeymapEventChannel>(window, Self::on_keymap_changed);let table_interaction_state = cx.new(|cx| {- TableInteractionState::new(cx)- .with_custom_scrollbar(ui::Scrollbars::for_settings::<editor::EditorSettings>())+ TableInteractionState::new(cx).with_custom_scrollbar(ui::Scrollbars::for_settings::<+ editor::EditorSettingsScrollbarProxy,+ >())});let keystroke_editor = cx.new(|cx| {@@ -2184,7 +2185,7 @@ impl Render for KeymapEditor {.cloned().unwrap_or_default().into_any_element(),- |binding| ui::KeyBinding::from_keystrokes(binding.keystrokes.clone(), binding.source).into_any_element()+ |binding| ui::KeyBinding::from_keystrokes(binding.keystrokes.clone(), binding.source == KeybindSource::Vim).into_any_element());let action_arguments = match binding.action().arguments.clone()diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rsindex 141c31a2690..aa6f89cb8c1 100644--- a/crates/outline_panel/src/outline_panel.rs+++ b/crates/outline_panel/src/outline_panel.rs@@ -62,6 +62,8 @@ use workspace::{};use worktree::{Entry, ProjectEntryId, WorktreeId};+use crate::outline_panel_settings::OutlinePanelSettingsScrollbarProxy;+actions!(outline_panel,[@@ -4805,7 +4807,7 @@ impl OutlinePanel {.size_full().child(list_contents.size_full().flex_shrink()).custom_scrollbars(- Scrollbars::for_settings::<OutlinePanelSettings>()+ Scrollbars::for_settings::<OutlinePanelSettingsScrollbarProxy>().tracked_scroll_handle(&self.scroll_handle.clone()).with_track_along(ScrollAxes::Horizontal,diff --git a/crates/outline_panel/src/outline_panel_settings.rs b/crates/outline_panel/src/outline_panel_settings.rsindex b744ca6399d..18f52e512da 100644--- a/crates/outline_panel/src/outline_panel_settings.rs+++ b/crates/outline_panel/src/outline_panel_settings.rs@@ -1,4 +1,4 @@-use editor::EditorSettings;+use editor::{EditorSettings, ui_scrollbar_settings_from_raw};use gpui::{App, Pixels};use settings::RegisterSetting;pub use settings::{DockSide, Settings, ShowIndentGuides};@@ -33,9 +33,13 @@ pub struct IndentGuidesSettings {pub show: ShowIndentGuides,}-impl ScrollbarVisibility for OutlinePanelSettings {+#[derive(Default)]+pub(crate) struct OutlinePanelSettingsScrollbarProxy;++impl ScrollbarVisibility for OutlinePanelSettingsScrollbarProxy {fn visibility(&self, cx: &App) -> ShowScrollbar {- self.scrollbar+ OutlinePanelSettings::get_global(cx)+ .scrollbar.show.unwrap_or_else(|| EditorSettings::get_global(cx).scrollbar.show)}@@ -65,7 +69,11 @@ impl Settings for OutlinePanelSettings {auto_reveal_entries: panel.auto_reveal_entries.unwrap(),auto_fold_dirs: panel.auto_fold_dirs.unwrap(),scrollbar: ScrollbarSettings {- show: panel.scrollbar.unwrap().show.map(Into::into),+ show: panel+ .scrollbar+ .unwrap()+ .show+ .map(ui_scrollbar_settings_from_raw),},expand_outlines_with_depth: panel.expand_outlines_with_depth.unwrap(),}diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rsindex aa8c86091d5..599afd99b37 100644--- a/crates/project_panel/src/project_panel.rs+++ b/crates/project_panel/src/project_panel.rs@@ -82,7 +82,10 @@ use zed_actions::{workspace::OpenWithSystem,};-use crate::undo::{ProjectPanelOperation, UndoManager};+use crate::{+ project_panel_settings::ProjectPanelScrollbarProxy,+ undo::{ProjectPanelOperation, UndoManager},+};const PROJECT_PANEL_KEY: &str = "ProjectPanel";const NEW_ENTRY_ID: ProjectEntryId = ProjectEntryId::MAX;@@ -7038,8 +7041,9 @@ impl Render for ProjectPanel {).custom_scrollbars({- let mut scrollbars = Scrollbars::for_settings::<ProjectPanelSettings>()- .tracked_scroll_handle(&self.scroll_handle);+ let mut scrollbars =+ Scrollbars::for_settings::<ProjectPanelScrollbarProxy>()+ .tracked_scroll_handle(&self.scroll_handle);if horizontal_scroll {scrollbars = scrollbars.with_track_along(ScrollAxes::Horizontal,diff --git a/crates/project_panel/src/project_panel_settings.rs b/crates/project_panel/src/project_panel_settings.rsindex d3786f371fd..64f3ea42928 100644--- a/crates/project_panel/src/project_panel_settings.rs+++ b/crates/project_panel/src/project_panel_settings.rs@@ -1,4 +1,4 @@-use editor::EditorSettings;+use editor::{EditorSettings, ui_scrollbar_settings_from_raw};use gpui::Pixels;use schemars::JsonSchema;use serde::{Deserialize, Serialize};@@ -81,9 +81,13 @@ impl AutoOpenSettings {}}-impl ScrollbarVisibility for ProjectPanelSettings {+#[derive(Default)]+pub(crate) struct ProjectPanelScrollbarProxy;++impl ScrollbarVisibility for ProjectPanelScrollbarProxy {fn visibility(&self, cx: &ui::App) -> ShowScrollbar {- self.scrollbar+ ProjectPanelSettings::get_global(cx)+ .scrollbar.show.unwrap_or_else(|| EditorSettings::get_global(cx).scrollbar.show)}@@ -120,7 +124,7 @@ impl Settings for ProjectPanelSettings {scrollbar: {let scrollbar = project_panel.scrollbar.unwrap();ScrollbarSettings {- show: scrollbar.show.map(Into::into),+ show: scrollbar.show.map(ui_scrollbar_settings_from_raw),horizontal_scroll: scrollbar.horizontal_scroll.unwrap(),}},diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rsindex 98b37eee576..b97a0845dba 100644--- a/crates/terminal_view/src/terminal_view.rs+++ b/crates/terminal_view/src/terminal_view.rs@@ -6,7 +6,10 @@ pub mod terminal_scrollbar;mod terminal_slash_command;use assistant_slash_command::SlashCommandRegistry;-use editor::{Editor, EditorSettings, actions::SelectAll, blink_manager::BlinkManager};+use editor::{+ Editor, EditorSettings, actions::SelectAll, blink_manager::BlinkManager,+ ui_scrollbar_settings_from_raw,+};use gpui::{Action, AnyElement, App, ClipboardEntry, DismissEvent, Entity, EventEmitter, ExternalPaths,FocusHandle, Focusable, Font, KeyContext, KeyDownEvent, Keystroke, MouseButton, MouseDownEvent,@@ -48,7 +51,7 @@ use terminal_slash_command::TerminalSlashCommand;use ui::{ContextMenu, Divider, ScrollAxes, Scrollbars, Tooltip, WithScrollbar,prelude::*,- scrollbars::{self, GlobalSetting, ScrollbarVisibility},+ scrollbars::{self, ScrollbarVisibility},};use util::ResultExt;use workspace::{@@ -1121,20 +1124,15 @@ fn regex_search_for_query(query: &SearchQuery) -> Option<RegexSearch> {}}+#[derive(Default)]struct TerminalScrollbarSettingsWrapper;-impl GlobalSetting for TerminalScrollbarSettingsWrapper {- fn get_value(_cx: &App) -> &Self {- &Self- }-}-impl ScrollbarVisibility for TerminalScrollbarSettingsWrapper {fn visibility(&self, cx: &App) -> scrollbars::ShowScrollbar {TerminalSettings::get_global(cx).scrollbar.show- .map(Into::into)+ .map(ui_scrollbar_settings_from_raw).unwrap_or_else(|| EditorSettings::get_global(cx).scrollbar.show)}}diff --git a/crates/ui/Cargo.toml b/crates/ui/Cargo.tomlindex 6ea1b6d26f7..05433bf8eeb 100644--- a/crates/ui/Cargo.toml+++ b/crates/ui/Cargo.toml@@ -23,7 +23,6 @@ itertools.workspace = truemenu.workspace = trueschemars.workspace = trueserde.workspace = true-settings.workspace = truesmallvec.workspace = truestory = { workspace = true, optional = true }strum.workspace = truediff --git a/crates/ui/src/components/keybinding.rs b/crates/ui/src/components/keybinding.rsindex 6c7efa4e49e..016181ee9bd 100644--- a/crates/ui/src/components/keybinding.rs+++ b/crates/ui/src/components/keybinding.rs@@ -8,7 +8,6 @@ use gpui::{Modifiers, Window, relative,};use itertools::Itertools;-use settings::KeybindSource;#[derive(Debug)]enum Source {@@ -103,11 +102,11 @@ impl KeyBinding {}}- pub fn from_keystrokes(keystrokes: Rc<[KeybindingKeystroke]>, source: KeybindSource) -> Self {+ pub fn from_keystrokes(keystrokes: Rc<[KeybindingKeystroke]>, vim_mode: bool) -> Self {Self {source: Source::Keystrokes { keystrokes },size: None,- vim_mode: source == KeybindSource::Vim,+ vim_mode,platform_style: PlatformStyle::platform(),disabled: false,}diff --git a/crates/ui/src/components/keybinding_hint.rs b/crates/ui/src/components/keybinding_hint.rsindex 7c19953ca43..9da470c4ee4 100644--- a/crates/ui/src/components/keybinding_hint.rs+++ b/crates/ui/src/components/keybinding_hint.rs@@ -14,11 +14,10 @@ use theme::Appearance;/// use gpui::{App, Hsla, KeybindingKeystroke, Keystroke};/// use ui::prelude::*;/// use ui::{KeyBinding, KeybindingHint};-/// use settings::KeybindSource;////// # fn example(cx: &App) {/// let hint = KeybindingHint::new(-/// KeyBinding::from_keystrokes(vec![KeybindingKeystroke::from_keystroke(Keystroke::parse("ctrl-s").unwrap())].into(), KeybindSource::Base),+/// KeyBinding::from_keystrokes(vec![KeybindingKeystroke::from_keystroke(Keystroke::parse("ctrl-s").unwrap())].into(), false),/// Hsla::black()/// )/// .prefix("Save:")@@ -46,11 +45,10 @@ impl KeybindingHint {/// use gpui::{App, Hsla, KeybindingKeystroke, Keystroke};/// use ui::prelude::*;/// use ui::{KeyBinding, KeybindingHint};- /// use settings::KeybindSource;////// # fn example(cx: &App) {/// let hint = KeybindingHint::new(- /// KeyBinding::from_keystrokes(vec![KeybindingKeystroke::from_keystroke(Keystroke::parse("ctrl-c").unwrap())].into(), KeybindSource::Base),+ /// KeyBinding::from_keystrokes(vec![KeybindingKeystroke::from_keystroke(Keystroke::parse("ctrl-c").unwrap())].into(), false),/// Hsla::black()/// );/// # }@@ -76,12 +74,11 @@ impl KeybindingHint {/// use gpui::{App, Hsla, KeybindingKeystroke, Keystroke};/// use ui::prelude::*;/// use ui::{KeyBinding, KeybindingHint};- /// use settings::KeybindSource;////// # fn example(cx: &App) {/// let hint = KeybindingHint::with_prefix(/// "Copy:",- /// KeyBinding::from_keystrokes(vec![KeybindingKeystroke::from_keystroke(Keystroke::parse("ctrl-c").unwrap())].into(), KeybindSource::Base),+ /// KeyBinding::from_keystrokes(vec![KeybindingKeystroke::from_keystroke(Keystroke::parse("ctrl-c").unwrap())].into(), false),/// Hsla::black()/// );/// # }@@ -111,11 +108,10 @@ impl KeybindingHint {/// use gpui::{App, Hsla, KeybindingKeystroke, Keystroke};/// use ui::prelude::*;/// use ui::{KeyBinding, KeybindingHint};- /// use settings::KeybindSource;////// # fn example(cx: &App) {/// let hint = KeybindingHint::with_suffix(- /// KeyBinding::from_keystrokes(vec![KeybindingKeystroke::from_keystroke(Keystroke::parse("ctrl-v").unwrap())].into(), KeybindSource::Base),+ /// KeyBinding::from_keystrokes(vec![KeybindingKeystroke::from_keystroke(Keystroke::parse("ctrl-v").unwrap())].into(), false),/// "Paste",/// Hsla::black()/// );@@ -145,11 +141,10 @@ impl KeybindingHint {/// use gpui::{App, Hsla, KeybindingKeystroke, Keystroke};/// use ui::prelude::*;/// use ui::{KeyBinding, KeybindingHint};- /// use settings::KeybindSource;////// # fn example(cx: &App) {/// let hint = KeybindingHint::new(- /// KeyBinding::from_keystrokes(vec![KeybindingKeystroke::from_keystroke(Keystroke::parse("ctrl-x").unwrap())].into(), KeybindSource::Base),+ /// KeyBinding::from_keystrokes(vec![KeybindingKeystroke::from_keystroke(Keystroke::parse("ctrl-x").unwrap())].into(), false),/// Hsla::black()/// )/// .prefix("Cut:");@@ -170,11 +165,10 @@ impl KeybindingHint {/// use gpui::{App, Hsla, KeybindingKeystroke, Keystroke};/// use ui::prelude::*;/// use ui::{KeyBinding, KeybindingHint};- /// use settings::KeybindSource;////// # fn example(cx: &App) {/// let hint = KeybindingHint::new(- /// KeyBinding::from_keystrokes(vec![KeybindingKeystroke::from_keystroke(Keystroke::parse("ctrl-f").unwrap())].into(), KeybindSource::Base),+ /// KeyBinding::from_keystrokes(vec![KeybindingKeystroke::from_keystroke(Keystroke::parse("ctrl-f").unwrap())].into(), false),/// Hsla::black()/// )/// .suffix("Find");@@ -195,11 +189,10 @@ impl KeybindingHint {/// use gpui::{App, Hsla, KeybindingKeystroke, Keystroke};/// use ui::prelude::*;/// use ui::{KeyBinding, KeybindingHint};- /// use settings::KeybindSource;////// # fn example(cx: &App) {/// let hint = KeybindingHint::new(- /// KeyBinding::from_keystrokes(vec![KeybindingKeystroke::from_keystroke(Keystroke::parse("ctrl-z").unwrap())].into(), KeybindSource::Base),+ /// KeyBinding::from_keystrokes(vec![KeybindingKeystroke::from_keystroke(Keystroke::parse("ctrl-z").unwrap())].into(), false),/// Hsla::black()/// )/// .size(Pixels::from(16.0));diff --git a/crates/ui/src/components/scrollbar.rs b/crates/ui/src/components/scrollbar.rsindex 795c5174fb4..86f5e3b4ccb 100644--- a/crates/ui/src/components/scrollbar.rs+++ b/crates/ui/src/components/scrollbar.rs@@ -16,7 +16,6 @@ use gpui::{size,};use gpui_util::ResultExt;-use settings::SettingsStore;use smallvec::SmallVec;use theme::ActiveTheme as _;@@ -34,7 +33,6 @@ pub mod scrollbars {use gpui::{App, Global};use schemars::JsonSchema;use serde::{Deserialize, Serialize};- use settings::Settings;/// When to show the scrollbar in the editor.///@@ -54,28 +52,7 @@ pub mod scrollbars {Never,}- impl From<settings::ShowScrollbar> for ShowScrollbar {- fn from(value: settings::ShowScrollbar) -> Self {- match value {- settings::ShowScrollbar::Auto => ShowScrollbar::Auto,- settings::ShowScrollbar::System => ShowScrollbar::System,- settings::ShowScrollbar::Always => ShowScrollbar::Always,- settings::ShowScrollbar::Never => ShowScrollbar::Never,- }- }- }-- pub trait GlobalSetting {- fn get_value(cx: &App) -> &Self;- }-- impl<T: Settings> GlobalSetting for T {- fn get_value(cx: &App) -> &T {- T::get_global(cx)- }- }-- pub trait ScrollbarVisibility: GlobalSetting + 'static {+ pub trait ScrollbarVisibility: 'static {fn visibility(&self, cx: &App) -> ShowScrollbar;}@@ -103,11 +80,9 @@ wherelet element_id = config.id.take().unwrap_or_else(|| caller_location.into());let track_color = config.track_color;- let state = window.use_keyed_state(element_id, cx, |window, cx| {+ let state = window.use_keyed_state(element_id, cx, |_, cx| {let parent_id = cx.entity_id();- ScrollbarStateWrapper(- cx.new(|cx| ScrollbarState::new_from_config(config, parent_id, window, cx)),- )+ ScrollbarStateWrapper(cx.new(|cx| ScrollbarState::new_from_config(config, parent_id, cx)))});state.update(cx, |state, cx| {@@ -399,8 +374,8 @@ impl Scrollbars {Self::new_with_setting(show_along, |_| ShowScrollbar::Always)}- pub fn for_settings<S: ScrollbarVisibility>() -> Scrollbars {- Scrollbars::new_with_setting(ScrollAxes::Both, |cx| S::get_value(cx).visibility(cx))+ pub fn for_settings<S: ScrollbarVisibility + Default>() -> Scrollbars {+ Scrollbars::new_with_setting(ScrollAxes::Both, |cx| S::default().visibility(cx))}}@@ -589,6 +564,16 @@ enum ParentHoverEvent {Outside,}+pub fn on_new_scrollbars<T: gpui::Global>(cx: &mut App) {+ cx.observe_new::<ScrollbarState>(|_, window, cx| {+ if let Some(window) = window {+ cx.observe_global_in::<T>(window, ScrollbarState::settings_changed)+ .detach();+ }+ })+ .detach();+}+/// This is used to ensure notifies within the state do not notify the parent/// unintentionally.struct ScrollbarStateWrapper<T: ScrollableHandle>(Entity<ScrollbarState<T>>);@@ -611,15 +596,7 @@ struct ScrollbarState<T: ScrollableHandle = ScrollHandle> {}impl<T: ScrollableHandle> ScrollbarState<T> {- fn new_from_config(- config: Scrollbars<T>,- parent_id: EntityId,- window: &mut Window,- cx: &mut Context<Self>,- ) -> Self {- cx.observe_global_in::<SettingsStore>(window, Self::settings_changed)- .detach();-+ fn new_from_config(config: Scrollbars<T>, parent_id: EntityId, cx: &mut Context<Self>) -> Self {let (manually_added, scroll_handle) = match config.scrollable_handle {Handle::Tracked(handle) => (true, handle),Handle::Untracked(func) => (false, func()),diff --git a/crates/ui/src/components/toggle.rs b/crates/ui/src/components/toggle.rsindex 86ff1d8eff8..0b1d7884687 100644--- a/crates/ui/src/components/toggle.rs+++ b/crates/ui/src/components/toggle.rs@@ -2,7 +2,6 @@ use gpui::{AnyElement, AnyView, ClickEvent, ElementId, Hsla, IntoElement, KeybindingKeystroke, Keystroke,Styled, Window, div, hsla, prelude::*,};-use settings::KeybindSource;use std::{rc::Rc, sync::Arc};use crate::utils::is_light;@@ -1051,7 +1050,7 @@ impl Component for Switch {Keystroke::parse("cmd-s").unwrap(),)].into(),- KeybindSource::Base,+ false,))).into_any_element(),)],diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rsindex f80608b8aaa..25e63abe6ce 100644--- a/crates/zed/src/main.rs+++ b/crates/zed/src/main.rs@@ -537,6 +537,7 @@ fn main() {tx.send(Some(options)).log_err();}).detach();+ ui::on_new_scrollbars::<SettingsStore>(cx);let node_runtime = NodeRuntime::new(client.http_client(), Some(shell_env_loaded_rx), rx);