Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
assistant2: Use `cmd-n` to create a new prompt editor when already in a prompt editor (#25935)
Bennet Bo Fenner909de2ca6f71
diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.jsonindex 91b236f5367..46da4215885 100644--- a/assets/keymaps/default-linux.json+++ b/assets/keymaps/default-linux.json@@ -612,6 +612,14 @@"ctrl-alt-e": "assistant2::RemoveAllContext"}},+ {+ "context": "AssistantPanel2 && prompt_editor",+ "use_key_equivalents": true,+ "bindings": {+ "cmd-n": "assistant2::NewPromptEditor",+ "cmd-alt-t": "assistant2::NewThread"+ }+ },{"context": "MessageEditor > Editor","bindings": {diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.jsonindex 73131005006..b2bced5e7dc 100644--- a/assets/keymaps/default-macos.json+++ b/assets/keymaps/default-macos.json@@ -256,6 +256,14 @@"cmd-alt-e": "assistant2::RemoveAllContext"}},+ {+ "context": "AssistantPanel2 && prompt_editor",+ "use_key_equivalents": true,+ "bindings": {+ "cmd-n": "assistant2::NewPromptEditor",+ "cmd-alt-t": "assistant2::NewThread"+ }+ },{"context": "MessageEditor > Editor","use_key_equivalents": true,diff --git a/crates/assistant2/src/assistant_panel.rs b/crates/assistant2/src/assistant_panel.rsindex 500f9744f28..ef04205e437 100644--- a/crates/assistant2/src/assistant_panel.rs+++ b/crates/assistant2/src/assistant_panel.rs@@ -15,7 +15,8 @@ use editor::Editor;use fs::Fs;use gpui::{prelude::*, Action, AnyElement, App, AsyncWindowContext, Corner, Entity, EventEmitter,- FocusHandle, Focusable, FontWeight, Pixels, Subscription, Task, UpdateGlobal, WeakEntity,+ FocusHandle, Focusable, FontWeight, KeyContext, Pixels, Subscription, Task, UpdateGlobal,+ WeakEntity,};use language::LanguageRegistry;use language_model::{LanguageModelProviderTosView, LanguageModelRegistry};@@ -993,12 +994,21 @@ impl AssistantPanel {).into_any()}++ fn key_context(&self) -> KeyContext {+ let mut key_context = KeyContext::new_with_defaults();+ key_context.add("AssistantPanel2");+ if matches!(self.active_view, ActiveView::PromptEditor) {+ key_context.add("prompt_editor");+ }+ key_context+ }}impl Render for AssistantPanel {fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {v_flex()- .key_context("AssistantPanel2")+ .key_context(self.key_context()).justify_between().size_full().on_action(cx.listener(Self::cancel))