Z 1200/replace in buffer (#2922)
This is still WIP, mostly pending styling. I added a pretty rudimentary text field and no buttons whatsoever other than that. I am targeting a Preview of 09.13, as I am gonna be on PTO for the next week. I dislike the current implementation slightly because of `regex`'s crate syntax and lack of support of backreferences. What strikes me as odd wrt to syntax is that it will just replace a capture name with empty string if that capture is missing from the regex. While this is perfectly fine behaviour for conditionally-matched capture groups (e.g. `(foo)?`), I think it should still error out if there's no group with a given name (conditional or not). Release Notes: - Added "Replace" functionality to buffer search.
This commit is contained in:
parent
c545788168
commit
4cb8647702
11 changed files with 471 additions and 96 deletions
|
@ -8,7 +8,9 @@ use gpui::{
|
|||
pub use mode::SearchMode;
|
||||
use project::search::SearchQuery;
|
||||
pub use project_search::{ProjectSearchBar, ProjectSearchView};
|
||||
use theme::components::{action_button::Button, svg::Svg, ComponentExt, ToggleIconButtonStyle};
|
||||
use theme::components::{
|
||||
action_button::Button, svg::Svg, ComponentExt, IconButtonStyle, ToggleIconButtonStyle,
|
||||
};
|
||||
|
||||
pub mod buffer_search;
|
||||
mod history;
|
||||
|
@ -27,6 +29,7 @@ actions!(
|
|||
CycleMode,
|
||||
ToggleWholeWord,
|
||||
ToggleCaseSensitive,
|
||||
ToggleReplace,
|
||||
SelectNextMatch,
|
||||
SelectPrevMatch,
|
||||
SelectAllMatches,
|
||||
|
@ -34,7 +37,9 @@ actions!(
|
|||
PreviousHistoryQuery,
|
||||
ActivateTextMode,
|
||||
ActivateSemanticMode,
|
||||
ActivateRegexMode
|
||||
ActivateRegexMode,
|
||||
ReplaceAll,
|
||||
ReplaceNext
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -98,3 +103,32 @@ impl SearchOptions {
|
|||
.into_any()
|
||||
}
|
||||
}
|
||||
|
||||
fn toggle_replace_button<V: View>(
|
||||
active: bool,
|
||||
tooltip_style: TooltipStyle,
|
||||
button_style: ToggleIconButtonStyle,
|
||||
) -> AnyElement<V> {
|
||||
Button::dynamic_action(Box::new(ToggleReplace))
|
||||
.with_tooltip("Toggle replace", tooltip_style)
|
||||
.with_contents(theme::components::svg::Svg::new("icons/replace.svg"))
|
||||
.toggleable(active)
|
||||
.with_style(button_style)
|
||||
.element()
|
||||
.into_any()
|
||||
}
|
||||
|
||||
fn replace_action<V: View>(
|
||||
action: impl Action,
|
||||
name: &'static str,
|
||||
icon_path: &'static str,
|
||||
tooltip_style: TooltipStyle,
|
||||
button_style: IconButtonStyle,
|
||||
) -> AnyElement<V> {
|
||||
Button::dynamic_action(Box::new(action))
|
||||
.with_tooltip(name, tooltip_style)
|
||||
.with_contents(theme::components::svg::Svg::new(icon_path))
|
||||
.with_style(button_style)
|
||||
.element()
|
||||
.into_any()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue