Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Touchups to registrar API
Piotr Osiewicz5ad125a9e93d
diff --git a/Cargo.lock b/Cargo.lockindex 43717420560..0316c343cb4 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -2486,7 +2486,6 @@ dependencies = ["postage","project","regex",- "search","serde","serde_derive","settings",diff --git a/crates/feedback/Cargo.toml b/crates/feedback/Cargo.tomlindex c6c8b9f4b24..e14df6a2d48 100644--- a/crates/feedback/Cargo.toml+++ b/crates/feedback/Cargo.toml@@ -18,7 +18,6 @@ gpui = { path = "../gpui" }language = { path = "../language" }menu = { path = "../menu" }project = { path = "../project" }-search = { path = "../search" }settings = { path = "../settings" }theme = { path = "../theme" }ui = { path = "../ui" }diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rsindex 3521b1e8490..afd0f6c6156 100644--- a/crates/search/src/buffer_search.rs+++ b/crates/search/src/buffer_search.rs@@ -431,57 +431,42 @@ pub trait SearchActionsRegistrar {}impl BufferSearchBar {- pub fn register_inner(- registrar: &mut impl SearchActionsRegistrar,- supported_options: &workspace::searchable::SearchOptions,- ) {- // supported_options controls whether the action is registered in the first place,- // but we still perform dynamic checks as e.g. if a view (like Workspace) uses SearchableItemHandle, they cannot know in advance- // whether a given option is supported.- if supported_options.case {- registrar.register_handler(|this, action: &ToggleCaseSensitive, cx| {- if this.supported_options().case {- this.toggle_case_sensitive(action, cx);- }- });- }- if supported_options.word {- registrar.register_handler(|this, action: &ToggleWholeWord, cx| {- if this.supported_options().word {- this.toggle_whole_word(action, cx);- }- });- }+ pub fn register_inner(registrar: &mut impl SearchActionsRegistrar) {+ registrar.register_handler(|this, action: &ToggleCaseSensitive, cx| {+ if this.supported_options().case {+ this.toggle_case_sensitive(action, cx);+ }+ });- if supported_options.replacement {- registrar.register_handler(|this, action: &ToggleReplace, cx| {- if this.supported_options().replacement {- this.toggle_replace(action, cx);- }- });- }+ registrar.register_handler(|this, action: &ToggleWholeWord, cx| {+ if this.supported_options().word {+ this.toggle_whole_word(action, cx);+ }+ });- if supported_options.regex {- registrar.register_handler(|this, _: &ActivateRegexMode, cx| {- if this.supported_options().regex {- this.activate_search_mode(SearchMode::Regex, cx);- }- });- }+ registrar.register_handler(|this, action: &ToggleReplace, cx| {+ if this.supported_options().replacement {+ this.toggle_replace(action, cx);+ }+ });++ registrar.register_handler(|this, _: &ActivateRegexMode, cx| {+ if this.supported_options().regex {+ this.activate_search_mode(SearchMode::Regex, cx);+ }+ });registrar.register_handler(|this, _: &ActivateTextMode, cx| {this.activate_search_mode(SearchMode::Text, cx);});- if supported_options.regex {- registrar.register_handler(|this, action: &CycleMode, cx| {- if this.supported_options().regex {- // If regex is not supported then search has just one mode (text) - in that case there's no point in supporting- // cycling.- this.cycle_mode(action, cx)- }- });- }+ registrar.register_handler(|this, action: &CycleMode, cx| {+ if this.supported_options().regex {+ // If regex is not supported then search has just one mode (text) - in that case there's no point in supporting+ // cycling.+ this.cycle_mode(action, cx)+ }+ });registrar.register_handler(|this, action: &SelectNextMatch, cx| {this.select_next_match(action, cx);@@ -500,6 +485,7 @@ impl BufferSearchBar {cx.propagate();});registrar.register_handler(|this, deploy, cx| {+ dbg!("Deploying?");this.deploy(deploy, cx);})}@@ -522,15 +508,7 @@ impl BufferSearchBar {});}}- Self::register_inner(- workspace,- &workspace::searchable::SearchOptions {- case: true,- word: true,- regex: true,- replacement: true,- },- );+ Self::register_inner(workspace);}pub fn new(cx: &mut ViewContext<Self>) -> Self {let query_editor = cx.new_view(|cx| Editor::single_line(cx));diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rsindex f363c5228bc..ed228faba8c 100644--- a/crates/terminal_view/src/terminal_panel.rs+++ b/crates/terminal_view/src/terminal_panel.rs@@ -19,7 +19,6 @@ use workspace::{dock::{DockPosition, Panel, PanelEvent},item::Item,pane,- searchable::SearchableItem,ui::Icon,Pane, Workspace,};@@ -359,7 +358,7 @@ impl Render for TerminalPanel {fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {let div = div();let mut registrar = ActionsRegistrar { div: Some(div), cx };- BufferSearchBar::register_inner(&mut registrar, &TerminalView::supported_options());+ BufferSearchBar::register_inner(&mut registrar);registrar.div.unwrap().size_full().child(self.pane.clone())}}