@@ -1,8 +1,8 @@
use crate::{
history::SearchHistory, mode::SearchMode, ActivateRegexMode, ActivateSemanticMode,
ActivateTextMode, CycleMode, NextHistoryQuery, PreviousHistoryQuery, ReplaceAll, ReplaceNext,
- SearchOptions, SelectNextMatch, SelectPrevMatch, ToggleCaseSensitive, ToggleReplace,
- ToggleWholeWord,
+ SearchOptions, SelectNextMatch, SelectPrevMatch, ToggleCaseSensitive, ToggleIncludeIgnored,
+ ToggleReplace, ToggleWholeWord,
};
use anyhow::{Context as _, Result};
use collections::HashMap;
@@ -1530,7 +1530,22 @@ impl Render for ProjectSearchBar {
.flex_1()
.border_1()
.mr_2()
- .child(search.included_files_editor.clone()),
+ .child(search.included_files_editor.clone())
+ .when(search.current_mode != SearchMode::Semantic, |this| {
+ this.child(
+ SearchOptions::INCLUDE_IGNORED.as_button(
+ search
+ .search_options
+ .contains(SearchOptions::INCLUDE_IGNORED),
+ cx.listener(|this, _, cx| {
+ this.toggle_search_option(
+ SearchOptions::INCLUDE_IGNORED,
+ cx,
+ );
+ }),
+ ),
+ )
+ }),
)
.child(
h_stack()
@@ -1671,34 +1686,14 @@ impl Render for ProjectSearchBar {
.on_action(cx.listener(|this, _: &ToggleFilters, cx| {
this.toggle_filters(cx);
}))
- .on_action(cx.listener(|this, _: &ToggleWholeWord, cx| {
- this.toggle_search_option(SearchOptions::WHOLE_WORD, cx);
- }))
- .on_action(cx.listener(|this, _: &ToggleCaseSensitive, cx| {
- this.toggle_search_option(SearchOptions::CASE_SENSITIVE, cx);
- }))
- .on_action(cx.listener(|this, action, cx| {
- this.toggle_replace(action, cx);
- }))
.on_action(cx.listener(|this, _: &ActivateTextMode, cx| {
this.activate_search_mode(SearchMode::Text, cx)
}))
.on_action(cx.listener(|this, _: &ActivateRegexMode, cx| {
this.activate_search_mode(SearchMode::Regex, cx)
}))
- .on_action(cx.listener(|this, action, cx| {
- if let Some(search) = this.active_project_search.as_ref() {
- search.update(cx, |this, cx| {
- this.replace_next(action, cx);
- })
- }
- }))
- .on_action(cx.listener(|this, action, cx| {
- if let Some(search) = this.active_project_search.as_ref() {
- search.update(cx, |this, cx| {
- this.replace_all(action, cx);
- })
- }
+ .on_action(cx.listener(|this, _: &ActivateSemanticMode, cx| {
+ this.activate_search_mode(SearchMode::Semantic, cx)
}))
.on_action(cx.listener(|this, action, cx| {
this.tab(action, cx);
@@ -1709,6 +1704,36 @@ impl Render for ProjectSearchBar {
.on_action(cx.listener(|this, action, cx| {
this.cycle_mode(action, cx);
}))
+ .when(search.current_mode != SearchMode::Semantic, |this| {
+ this.on_action(cx.listener(|this, action, cx| {
+ this.toggle_replace(action, cx);
+ }))
+ .on_action(cx.listener(|this, _: &ToggleWholeWord, cx| {
+ this.toggle_search_option(SearchOptions::WHOLE_WORD, cx);
+ }))
+ .on_action(cx.listener(|this, _: &ToggleCaseSensitive, cx| {
+ this.toggle_search_option(SearchOptions::CASE_SENSITIVE, cx);
+ }))
+ .on_action(cx.listener(|this, action, cx| {
+ if let Some(search) = this.active_project_search.as_ref() {
+ search.update(cx, |this, cx| {
+ this.replace_next(action, cx);
+ })
+ }
+ }))
+ .on_action(cx.listener(|this, action, cx| {
+ if let Some(search) = this.active_project_search.as_ref() {
+ search.update(cx, |this, cx| {
+ this.replace_all(action, cx);
+ })
+ }
+ }))
+ .when(search.filters_enabled, |this| {
+ this.on_action(cx.listener(|this, _: &ToggleIncludeIgnored, cx| {
+ this.toggle_search_option(SearchOptions::INCLUDE_IGNORED, cx);
+ }))
+ })
+ })
.child(query_column)
.child(mode_column)
.child(replace_column)
@@ -28,6 +28,7 @@ actions!(
CycleMode,
ToggleWholeWord,
ToggleCaseSensitive,
+ ToggleIncludeIgnored,
ToggleReplace,
SelectNextMatch,
SelectPrevMatch,
@@ -57,6 +58,7 @@ impl SearchOptions {
match *self {
SearchOptions::WHOLE_WORD => "Match Whole Word",
SearchOptions::CASE_SENSITIVE => "Match Case",
+ SearchOptions::INCLUDE_IGNORED => "Include ignored",
_ => panic!("{:?} is not a named SearchOption", self),
}
}
@@ -65,6 +67,7 @@ impl SearchOptions {
match *self {
SearchOptions::WHOLE_WORD => ui::Icon::WholeWord,
SearchOptions::CASE_SENSITIVE => ui::Icon::CaseSensitive,
+ SearchOptions::INCLUDE_IGNORED => ui::Icon::FileGit,
_ => panic!("{:?} is not a named SearchOption", self),
}
}
@@ -73,6 +76,7 @@ impl SearchOptions {
match *self {
SearchOptions::WHOLE_WORD => Box::new(ToggleWholeWord),
SearchOptions::CASE_SENSITIVE => Box::new(ToggleCaseSensitive),
+ SearchOptions::INCLUDE_IGNORED => Box::new(ToggleIncludeIgnored),
_ => panic!("{:?} is not a named SearchOption", self),
}
}
@@ -85,6 +89,7 @@ impl SearchOptions {
let mut options = SearchOptions::NONE;
options.set(SearchOptions::WHOLE_WORD, query.whole_word());
options.set(SearchOptions::CASE_SENSITIVE, query.case_sensitive());
+ options.set(SearchOptions::INCLUDE_IGNORED, query.include_ignored());
options
}