mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-17 23:56:55 +00:00
de9bf6dfbd
There may have been a good reason for the difference at some point, or I was still learning Rust. But now it's just &mut AppContext vs &AppContext.
47 lines
1.1 KiB
Rust
47 lines
1.1 KiB
Rust
pub use buffer_search::BufferSearchBar;
|
|
use gpui::{actions, Action, AppContext};
|
|
pub use project_search::{ProjectSearchBar, ProjectSearchView};
|
|
|
|
pub mod buffer_search;
|
|
pub mod project_search;
|
|
|
|
pub fn init(cx: &mut AppContext) {
|
|
buffer_search::init(cx);
|
|
project_search::init(cx);
|
|
}
|
|
|
|
actions!(
|
|
search,
|
|
[
|
|
ToggleWholeWord,
|
|
ToggleCaseSensitive,
|
|
ToggleRegex,
|
|
SelectNextMatch,
|
|
SelectPrevMatch
|
|
]
|
|
);
|
|
|
|
#[derive(Clone, Copy, PartialEq)]
|
|
pub enum SearchOption {
|
|
WholeWord,
|
|
CaseSensitive,
|
|
Regex,
|
|
}
|
|
|
|
impl SearchOption {
|
|
pub fn label(&self) -> &'static str {
|
|
match self {
|
|
SearchOption::WholeWord => "Match Whole Word",
|
|
SearchOption::CaseSensitive => "Match Case",
|
|
SearchOption::Regex => "Use Regular Expression",
|
|
}
|
|
}
|
|
|
|
pub fn to_toggle_action(&self) -> Box<dyn Action> {
|
|
match self {
|
|
SearchOption::WholeWord => Box::new(ToggleWholeWord),
|
|
SearchOption::CaseSensitive => Box::new(ToggleCaseSensitive),
|
|
SearchOption::Regex => Box::new(ToggleRegex),
|
|
}
|
|
}
|
|
}
|