Finish migration to modes for buffer search
This commit is contained in:
parent
fecea03c90
commit
343e9d080e
4 changed files with 20 additions and 15 deletions
|
@ -158,7 +158,7 @@ impl View for BufferSearchBar {
|
||||||
mode,
|
mode,
|
||||||
is_active,
|
is_active,
|
||||||
move |_, this, cx| {
|
move |_, this, cx| {
|
||||||
//this.activate_search_mode(mode, cx);
|
this.activate_search_mode(mode, cx);
|
||||||
},
|
},
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
|
@ -222,12 +222,6 @@ impl View for BufferSearchBar {
|
||||||
SearchOptions::WHOLE_WORD,
|
SearchOptions::WHOLE_WORD,
|
||||||
cx,
|
cx,
|
||||||
))
|
))
|
||||||
/*.with_children(self.render_search_option(
|
|
||||||
supported_options.regex,
|
|
||||||
"Regex",
|
|
||||||
SearchOptions::REGEX,
|
|
||||||
cx,
|
|
||||||
))*/
|
|
||||||
.contained()
|
.contained()
|
||||||
.with_style(theme.search.option_button_group)
|
.with_style(theme.search.option_button_group)
|
||||||
.aligned(),
|
.aligned(),
|
||||||
|
@ -537,7 +531,19 @@ impl BufferSearchBar {
|
||||||
)
|
)
|
||||||
.into_any()
|
.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>) {
|
fn deploy(pane: &mut Pane, action: &Deploy, cx: &mut ViewContext<Pane>) {
|
||||||
let mut propagate_action = true;
|
let mut propagate_action = true;
|
||||||
if let Some(search_bar) = pane.toolbar().read(cx).item_of_type::<BufferSearchBar>() {
|
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);
|
active_searchable_item.clear_matches(cx);
|
||||||
let _ = done_tx.send(());
|
let _ = done_tx.send(());
|
||||||
} else {
|
} else {
|
||||||
let query = if true {
|
let query = if self.current_mode == SearchMode::Regex {
|
||||||
match SearchQuery::regex(
|
match SearchQuery::regex(
|
||||||
query,
|
query,
|
||||||
self.search_options.contains(SearchOptions::WHOLE_WORD),
|
self.search_options.contains(SearchOptions::WHOLE_WORD),
|
||||||
|
|
|
@ -3,7 +3,7 @@ use gpui::Action;
|
||||||
use crate::{ActivateRegexMode, ActivateSemanticMode, ActivateTextMode};
|
use crate::{ActivateRegexMode, ActivateSemanticMode, ActivateTextMode};
|
||||||
// TODO: Update the default search mode to get from config
|
// TODO: Update the default search mode to get from config
|
||||||
#[derive(Copy, Clone, Debug, Default, PartialEq)]
|
#[derive(Copy, Clone, Debug, Default, PartialEq)]
|
||||||
pub(crate) enum SearchMode {
|
pub enum SearchMode {
|
||||||
#[default]
|
#[default]
|
||||||
Text,
|
Text,
|
||||||
Semantic,
|
Semantic,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
pub use buffer_search::BufferSearchBar;
|
pub use buffer_search::BufferSearchBar;
|
||||||
use gpui::{actions, Action, AppContext};
|
use gpui::{actions, Action, AppContext};
|
||||||
|
pub use mode::SearchMode;
|
||||||
use project::search::SearchQuery;
|
use project::search::SearchQuery;
|
||||||
pub use project_search::{ProjectSearchBar, ProjectSearchView};
|
pub use project_search::{ProjectSearchBar, ProjectSearchView};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use gpui::{actions, impl_actions, AppContext, ViewContext};
|
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 serde_derive::Deserialize;
|
||||||
use workspace::{searchable::Direction, Pane, Workspace};
|
use workspace::{searchable::Direction, Pane, Workspace};
|
||||||
|
|
||||||
|
@ -65,10 +65,8 @@ fn search(workspace: &mut Workspace, action: &Search, cx: &mut ViewContext<Works
|
||||||
cx.focus_self();
|
cx.focus_self();
|
||||||
|
|
||||||
if query.is_empty() {
|
if query.is_empty() {
|
||||||
search_bar.set_search_options(
|
search_bar.set_search_options(SearchOptions::CASE_SENSITIVE, cx);
|
||||||
SearchOptions::CASE_SENSITIVE, // | SearchOptions::REGEX,
|
search_bar.activate_search_mode(SearchMode::Regex, cx);
|
||||||
cx,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
vim.state.search = SearchState {
|
vim.state.search = SearchState {
|
||||||
direction,
|
direction,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue