Improve Linux terminal keymap and context menu (#16845)

Follow-up https://github.com/zed-industries/zed/pull/16085 that fixes
the search deploy to be actually a part of the terminal-related
bindings.

Part of https://github.com/zed-industries/zed/issues/16839

Also 

* fixes few other bindings to use `shift` and avoid conflicts with the
existing key bindings.
* adds terminal inline assist to the context menu and makes both the
menu and the button to dynamically adjust to `assist.enabled` settings
change

It is still unclear to me, why certain labels for certain bindings are
wrong (it's still showing `ctrl-w` for closing the terminal tab, and
`shift-insert` instead of `ctrl-shift-v` for Paste, while Insert is near
and has a `ctrl-shift-c` binding shown) but at least the keys work now.

Release notes: 
- Improved Linux terminal keymap and context menu
This commit is contained in:
Kirill Bulatov 2024-08-26 01:01:46 +03:00 committed by GitHub
parent 28271a9a36
commit 1a2a538366
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 87 additions and 50 deletions

View file

@ -12,10 +12,10 @@ use crate::{
slash_command_picker,
terminal_inline_assistant::TerminalInlineAssistant,
Assist, CacheStatus, ConfirmCommand, Context, ContextEvent, ContextId, ContextStore,
CycleMessageRole, DeployHistory, DeployPromptLibrary, InlineAssist, InlineAssistId,
InlineAssistant, InsertIntoEditor, MessageStatus, ModelSelector, PendingSlashCommand,
PendingSlashCommandStatus, QuoteSelection, RemoteContextMetadata, SavedContextMetadata, Split,
ToggleFocus, ToggleModelSelector, WorkflowStepResolution, WorkflowStepView,
CycleMessageRole, DeployHistory, DeployPromptLibrary, InlineAssistId, InlineAssistant,
InsertIntoEditor, MessageStatus, ModelSelector, PendingSlashCommand, PendingSlashCommandStatus,
QuoteSelection, RemoteContextMetadata, SavedContextMetadata, Split, ToggleFocus,
ToggleModelSelector, WorkflowStepResolution, WorkflowStepView,
};
use crate::{ContextStoreEvent, ModelPickerDelegate};
use anyhow::{anyhow, Result};
@ -82,6 +82,7 @@ use workspace::{
ToolbarItemView, Workspace,
};
use workspace::{searchable::SearchableItemHandle, NewFile};
use zed_actions::InlineAssist;
pub fn init(cx: &mut AppContext) {
workspace::FollowableViewRegistry::register::<ContextEditor>(cx);
@ -107,29 +108,12 @@ pub fn init(cx: &mut AppContext) {
cx.observe_new_views(
|terminal_panel: &mut TerminalPanel, cx: &mut ViewContext<TerminalPanel>| {
let settings = AssistantSettings::get_global(cx);
if !settings.enabled {
return;
}
terminal_panel.register_tab_bar_button(cx.new_view(|_| InlineAssistTabBarButton), cx);
terminal_panel.asssistant_enabled(settings.enabled, cx);
},
)
.detach();
}
struct InlineAssistTabBarButton;
impl Render for InlineAssistTabBarButton {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
IconButton::new("terminal_inline_assistant", IconName::ZedAssistant)
.icon_size(IconSize::Small)
.on_click(cx.listener(|_, _, cx| {
cx.dispatch_action(InlineAssist::default().boxed_clone());
}))
.tooltip(move |cx| Tooltip::for_action("Inline Assist", &InlineAssist::default(), cx))
}
}
pub enum AssistantPanelEvent {
ContextEdited,
}