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

@ -25,6 +25,7 @@ use terminal::{
TerminalSize,
};
use terminal_element::{is_blank, TerminalElement};
use terminal_panel::TerminalPanel;
use ui::{h_flex, prelude::*, ContextMenu, Icon, IconName, Label, Tooltip};
use util::{paths::PathWithPosition, ResultExt};
use workspace::{
@ -40,6 +41,7 @@ use anyhow::Context;
use serde::Deserialize;
use settings::{Settings, SettingsStore};
use smol::Timer;
use zed_actions::InlineAssist;
use std::{
cmp,
@ -210,6 +212,13 @@ impl TerminalView {
position: gpui::Point<Pixels>,
cx: &mut ViewContext<Self>,
) {
let assistant_enabled = self
.workspace
.upgrade()
.and_then(|workspace| workspace.read(cx).panel::<TerminalPanel>(cx))
.map_or(false, |terminal_panel| {
terminal_panel.read(cx).assistant_enabled()
});
let context_menu = ContextMenu::build(cx, |menu, _| {
menu.context(self.focus_handle.clone())
.action("New Terminal", Box::new(NewTerminal))
@ -218,6 +227,10 @@ impl TerminalView {
.action("Paste", Box::new(Paste))
.action("Select All", Box::new(SelectAll))
.action("Clear", Box::new(Clear))
.when(assistant_enabled, |menu| {
menu.separator()
.action("Inline Assist", Box::new(InlineAssist::default()))
})
.separator()
.action("Close", Box::new(CloseActiveItem { save_intent: None }))
});