Load project and buffer search key bindings from JSON file

This commit is contained in:
Max Brunsfeld 2022-04-10 11:30:08 -07:00
parent 3636c9ec25
commit 1e2eeaa22a
3 changed files with 37 additions and 35 deletions

View file

@ -5,9 +5,9 @@ use crate::{
use collections::HashMap;
use editor::{display_map::ToDisplayPoint, Anchor, Autoscroll, Bias, Editor};
use gpui::{
actions, elements::*, impl_actions, impl_internal_actions, keymap::Binding,
platform::CursorStyle, AppContext, Entity, MutableAppContext, RenderContext, Subscription,
Task, View, ViewContext, ViewHandle, WeakViewHandle,
actions, elements::*, impl_actions, impl_internal_actions, platform::CursorStyle, AppContext,
Entity, MutableAppContext, RenderContext, Subscription, Task, View, ViewContext, ViewHandle,
WeakViewHandle,
};
use language::OffsetRangeExt;
use project::search::SearchQuery;
@ -33,24 +33,6 @@ pub enum Event {
}
pub fn init(cx: &mut MutableAppContext) {
cx.add_bindings([
Binding::new(
"cmd-f",
Deploy { focus: true },
Some("Editor && mode == full"),
),
Binding::new(
"cmd-e",
Deploy { focus: false },
Some("Editor && mode == full"),
),
Binding::new("escape", Dismiss, Some("BufferSearchBar")),
Binding::new("cmd-f", FocusEditor, Some("BufferSearchBar")),
Binding::new("enter", SelectNextMatch, Some("BufferSearchBar")),
Binding::new("shift-enter", SelectPrevMatch, Some("BufferSearchBar")),
Binding::new("cmd-g", SelectNextMatch, Some("Pane")),
Binding::new("cmd-shift-G", SelectPrevMatch, Some("Pane")),
]);
cx.add_action(BufferSearchBar::deploy);
cx.add_action(BufferSearchBar::dismiss);
cx.add_action(BufferSearchBar::focus_editor);

View file

@ -5,9 +5,9 @@ use crate::{
use collections::HashMap;
use editor::{Anchor, Autoscroll, Editor, MultiBuffer, SelectAll};
use gpui::{
actions, elements::*, keymap::Binding, platform::CursorStyle, AppContext, ElementBox, Entity,
ModelContext, ModelHandle, MutableAppContext, RenderContext, Subscription, Task, View,
ViewContext, ViewHandle, WeakModelHandle, WeakViewHandle,
actions, elements::*, platform::CursorStyle, AppContext, ElementBox, Entity, ModelContext,
ModelHandle, MutableAppContext, RenderContext, Subscription, Task, View, ViewContext,
ViewHandle, WeakModelHandle, WeakViewHandle,
};
use project::{search::SearchQuery, Project};
use settings::Settings;
@ -28,15 +28,6 @@ struct ActiveSearches(HashMap<WeakModelHandle<Project>, WeakViewHandle<ProjectSe
pub fn init(cx: &mut MutableAppContext) {
cx.set_global(ActiveSearches::default());
cx.add_bindings([
Binding::new("cmd-shift-F", ToggleFocus, Some("Pane")),
Binding::new("cmd-f", ToggleFocus, Some("Pane")),
Binding::new("cmd-shift-F", Deploy, Some("Workspace")),
Binding::new("enter", Search, Some("ProjectSearchBar")),
Binding::new("cmd-enter", SearchInNew, Some("ProjectSearchBar")),
Binding::new("cmd-g", SelectNextMatch, Some("Pane")),
Binding::new("cmd-shift-G", SelectPrevMatch, Some("Pane")),
]);
cx.add_action(ProjectSearchView::deploy);
cx.add_action(ProjectSearchBar::search);
cx.add_action(ProjectSearchBar::search_in_new);