Detailed changes
@@ -158,7 +158,7 @@ impl View for BufferSearchBar {
mode,
is_active,
move |_, this, cx| {
- //this.activate_search_mode(mode, cx);
+ this.activate_search_mode(mode, cx);
},
cx,
)
@@ -222,12 +222,6 @@ impl View for BufferSearchBar {
SearchOptions::WHOLE_WORD,
cx,
))
- /*.with_children(self.render_search_option(
- supported_options.regex,
- "Regex",
- SearchOptions::REGEX,
- cx,
- ))*/
.contained()
.with_style(theme.search.option_button_group)
.aligned(),
@@ -537,7 +531,19 @@ impl BufferSearchBar {
)
.into_any()
}
-
+ pub fn activate_search_mode(&mut self, mode: SearchMode, cx: &mut ViewContext<Self>) {
+ assert_ne!(
+ mode,
+ SearchMode::Semantic,
+ "Semantic search is not supported in buffer search"
+ );
+ if mode == self.current_mode {
+ return;
+ }
+ self.current_mode = mode;
+ let _ = self.update_matches(cx);
+ cx.notify();
+ }
fn deploy(pane: &mut Pane, action: &Deploy, cx: &mut ViewContext<Pane>) {
let mut propagate_action = true;
if let Some(search_bar) = pane.toolbar().read(cx).item_of_type::<BufferSearchBar>() {
@@ -713,7 +719,7 @@ impl BufferSearchBar {
active_searchable_item.clear_matches(cx);
let _ = done_tx.send(());
} else {
- let query = if true {
+ let query = if self.current_mode == SearchMode::Regex {
match SearchQuery::regex(
query,
self.search_options.contains(SearchOptions::WHOLE_WORD),
@@ -3,7 +3,7 @@ use gpui::Action;
use crate::{ActivateRegexMode, ActivateSemanticMode, ActivateTextMode};
// TODO: Update the default search mode to get from config
#[derive(Copy, Clone, Debug, Default, PartialEq)]
-pub(crate) enum SearchMode {
+pub enum SearchMode {
#[default]
Text,
Semantic,
@@ -1,6 +1,7 @@
use bitflags::bitflags;
pub use buffer_search::BufferSearchBar;
use gpui::{actions, Action, AppContext};
+pub use mode::SearchMode;
use project::search::SearchQuery;
pub use project_search::{ProjectSearchBar, ProjectSearchView};
@@ -1,5 +1,5 @@
use gpui::{actions, impl_actions, AppContext, ViewContext};
-use search::{buffer_search, BufferSearchBar, SearchOptions};
+use search::{buffer_search, BufferSearchBar, SearchMode, SearchOptions};
use serde_derive::Deserialize;
use workspace::{searchable::Direction, Pane, Workspace};
@@ -65,10 +65,8 @@ fn search(workspace: &mut Workspace, action: &Search, cx: &mut ViewContext<Works
cx.focus_self();
if query.is_empty() {
- search_bar.set_search_options(
- SearchOptions::CASE_SENSITIVE, // | SearchOptions::REGEX,
- cx,
- );
+ search_bar.set_search_options(SearchOptions::CASE_SENSITIVE, cx);
+ search_bar.activate_search_mode(SearchMode::Regex, cx);
}
vim.state.search = SearchState {
direction,