fixup! Move away from using cx.dispatch_action in buffer search
This commit is contained in:
parent
be57059195
commit
13f9fec0bd
2 changed files with 16 additions and 6 deletions
|
@ -154,10 +154,21 @@ impl Render for BufferSearchBar {
|
||||||
Some(ui::Label::new(message))
|
Some(ui::Label::new(message))
|
||||||
});
|
});
|
||||||
let should_show_replace_input = self.replace_enabled && supported_options.replacement;
|
let should_show_replace_input = self.replace_enabled && supported_options.replacement;
|
||||||
let replace_all = should_show_replace_input
|
let replace_all = should_show_replace_input.then(|| {
|
||||||
.then(|| super::render_replace_button(ReplaceAll, ui::Icon::ReplaceAll, "Replace all"));
|
super::render_replace_button(
|
||||||
|
ReplaceAll,
|
||||||
|
ui::Icon::ReplaceAll,
|
||||||
|
"Replace all",
|
||||||
|
cx.listener(|this, _, cx| this.replace_all(&ReplaceAll, cx)),
|
||||||
|
)
|
||||||
|
});
|
||||||
let replace_next = should_show_replace_input.then(|| {
|
let replace_next = should_show_replace_input.then(|| {
|
||||||
super::render_replace_button(ReplaceNext, ui::Icon::ReplaceNext, "Replace next")
|
super::render_replace_button(
|
||||||
|
ReplaceNext,
|
||||||
|
ui::Icon::ReplaceNext,
|
||||||
|
"Replace next",
|
||||||
|
cx.listener(|this, _, cx| this.replace_next(&ReplaceNext, cx)),
|
||||||
|
)
|
||||||
});
|
});
|
||||||
let in_replace = self.replacement_editor.focus_handle(cx).is_focused(cx);
|
let in_replace = self.replacement_editor.focus_handle(cx).is_focused(cx);
|
||||||
|
|
||||||
|
|
|
@ -121,6 +121,7 @@ fn render_replace_button(
|
||||||
action: impl Action + 'static + Send + Sync,
|
action: impl Action + 'static + Send + Sync,
|
||||||
icon: Icon,
|
icon: Icon,
|
||||||
tooltip: &'static str,
|
tooltip: &'static str,
|
||||||
|
on_click: impl Fn(&gpui::ClickEvent, &mut WindowContext) + 'static,
|
||||||
) -> impl IntoElement {
|
) -> impl IntoElement {
|
||||||
let id: SharedString = format!("search-replace-{}", action.name()).into();
|
let id: SharedString = format!("search-replace-{}", action.name()).into();
|
||||||
IconButton::new(id, icon)
|
IconButton::new(id, icon)
|
||||||
|
@ -128,7 +129,5 @@ fn render_replace_button(
|
||||||
let action = action.boxed_clone();
|
let action = action.boxed_clone();
|
||||||
move |cx| Tooltip::for_action(tooltip, &*action, cx)
|
move |cx| Tooltip::for_action(tooltip, &*action, cx)
|
||||||
})
|
})
|
||||||
.on_click(move |_, cx| {
|
.on_click(on_click)
|
||||||
cx.dispatch_action(action.boxed_clone());
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue