mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-03 17:44:30 +00:00
update keymaps for cycle search mode and toggle filters
This commit is contained in:
parent
acf78f5fb4
commit
71bbd5f2f6
2 changed files with 31 additions and 9 deletions
|
@ -229,13 +229,15 @@
|
||||||
{
|
{
|
||||||
"context": "ProjectSearchBar",
|
"context": "ProjectSearchBar",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"escape": "project_search::ToggleFocus"
|
"escape": "project_search::ToggleFocus",
|
||||||
|
"alt-tab": "project_search::CycleMode",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"context": "ProjectSearchView",
|
"context": "ProjectSearchView",
|
||||||
"bindings": {
|
"bindings": {
|
||||||
"escape": "project_search::ToggleFocus"
|
"escape": "project_search::ToggleFocus",
|
||||||
|
"alt-tab": "project_search::CycleMode"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -247,7 +249,8 @@
|
||||||
"alt-enter": "search::SelectAllMatches",
|
"alt-enter": "search::SelectAllMatches",
|
||||||
"alt-cmd-c": "search::ToggleCaseSensitive",
|
"alt-cmd-c": "search::ToggleCaseSensitive",
|
||||||
"alt-cmd-w": "search::ToggleWholeWord",
|
"alt-cmd-w": "search::ToggleWholeWord",
|
||||||
"alt-cmd-r": "search::ToggleRegex"
|
"alt-cmd-r": "search::ToggleRegex",
|
||||||
|
"alt-cmd-f": "project_search::ToggleFilters"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Bindings from VS Code
|
// Bindings from VS Code
|
||||||
|
|
|
@ -50,6 +50,7 @@ actions!(
|
||||||
ToggleFocus,
|
ToggleFocus,
|
||||||
NextField,
|
NextField,
|
||||||
CycleMode,
|
CycleMode,
|
||||||
|
ToggleFilters,
|
||||||
ActivateTextMode,
|
ActivateTextMode,
|
||||||
ActivateSemanticMode,
|
ActivateSemanticMode,
|
||||||
ActivateRegexMode
|
ActivateRegexMode
|
||||||
|
@ -72,6 +73,18 @@ pub fn init(cx: &mut AppContext) {
|
||||||
cx.capture_action(ProjectSearchBar::tab_previous);
|
cx.capture_action(ProjectSearchBar::tab_previous);
|
||||||
add_toggle_option_action::<ToggleCaseSensitive>(SearchOptions::CASE_SENSITIVE, cx);
|
add_toggle_option_action::<ToggleCaseSensitive>(SearchOptions::CASE_SENSITIVE, cx);
|
||||||
add_toggle_option_action::<ToggleWholeWord>(SearchOptions::WHOLE_WORD, cx);
|
add_toggle_option_action::<ToggleWholeWord>(SearchOptions::WHOLE_WORD, cx);
|
||||||
|
add_toggle_filters_action::<ToggleFilters>(cx);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add_toggle_filters_action<A: Action>(cx: &mut AppContext) {
|
||||||
|
cx.add_action(move |pane: &mut Pane, _: &A, cx: &mut ViewContext<Pane>| {
|
||||||
|
if let Some(search_bar) = pane.toolbar().read(cx).item_of_type::<ProjectSearchBar>() {
|
||||||
|
if search_bar.update(cx, |search_bar, cx| search_bar.toggle_filters(cx)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cx.propagate_action();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_toggle_option_action<A: Action>(option: SearchOptions, cx: &mut AppContext) {
|
fn add_toggle_option_action<A: Action>(option: SearchOptions, cx: &mut AppContext) {
|
||||||
|
@ -380,7 +393,7 @@ impl View for ProjectSearchView {
|
||||||
let dots_count = semantic.outstanding_file_count % 3 + 1;
|
let dots_count = semantic.outstanding_file_count % 3 + 1;
|
||||||
let dots: String = std::iter::repeat('.').take(dots_count).collect();
|
let dots: String = std::iter::repeat('.').take(dots_count).collect();
|
||||||
format!(
|
format!(
|
||||||
"Indexing. {} of {}{dots}",
|
"Indexing: {} of {}{dots}",
|
||||||
semantic.file_count - semantic.outstanding_file_count,
|
semantic.file_count - semantic.outstanding_file_count,
|
||||||
semantic.file_count
|
semantic.file_count
|
||||||
)
|
)
|
||||||
|
@ -388,13 +401,13 @@ impl View for ProjectSearchView {
|
||||||
"Indexing complete".to_string()
|
"Indexing complete".to_string()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
"This is an invalid state".to_string()
|
"Indexing: ...".to_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
let minor_text = match current_mode {
|
let minor_text = match current_mode {
|
||||||
SearchMode::Semantic => [
|
SearchMode::Semantic => [
|
||||||
semantic_status,
|
semantic_status,
|
||||||
"ex. list all available languages".to_owned(),
|
"ex. 'list all available languages'".to_owned(),
|
||||||
],
|
],
|
||||||
_ => [
|
_ => [
|
||||||
"Include/exclude specific paths with the filter option.".to_owned(),
|
"Include/exclude specific paths with the filter option.".to_owned(),
|
||||||
|
@ -1396,8 +1409,6 @@ impl ProjectSearchBar {
|
||||||
search_view
|
search_view
|
||||||
.excluded_files_editor
|
.excluded_files_editor
|
||||||
.update(cx, |_, cx| cx.notify());
|
.update(cx, |_, cx| cx.notify());
|
||||||
search_view.semantic = None;
|
|
||||||
search_view.search(cx);
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
});
|
});
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
@ -1518,6 +1529,7 @@ impl ProjectSearchBar {
|
||||||
|
|
||||||
if button_side == Side::Left {
|
if button_side == Side::Left {
|
||||||
Flex::row()
|
Flex::row()
|
||||||
|
.align_children_center()
|
||||||
.with_child(
|
.with_child(
|
||||||
ButtonSide::left(
|
ButtonSide::left(
|
||||||
style
|
style
|
||||||
|
@ -1534,6 +1546,7 @@ impl ProjectSearchBar {
|
||||||
.into_any()
|
.into_any()
|
||||||
} else {
|
} else {
|
||||||
Flex::row()
|
Flex::row()
|
||||||
|
.align_children_center()
|
||||||
.with_child(label)
|
.with_child(label)
|
||||||
.with_child(
|
.with_child(
|
||||||
ButtonSide::right(
|
ButtonSide::right(
|
||||||
|
@ -1646,7 +1659,13 @@ impl View for ProjectSearchBar {
|
||||||
this.toggle_filters(cx);
|
this.toggle_filters(cx);
|
||||||
})
|
})
|
||||||
.with_cursor_style(CursorStyle::PointingHand)
|
.with_cursor_style(CursorStyle::PointingHand)
|
||||||
.with_tooltip::<Self>(0, "Toggle filters".into(), None, tooltip_style, cx)
|
.with_tooltip::<Self>(
|
||||||
|
0,
|
||||||
|
"Toggle filters".into(),
|
||||||
|
Some(Box::new(ToggleFilters)),
|
||||||
|
tooltip_style,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
.into_any()
|
.into_any()
|
||||||
};
|
};
|
||||||
let search = _search.read(cx);
|
let search = _search.read(cx);
|
||||||
|
|
Loading…
Reference in a new issue