Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Expose active key equivalents in the keymap context view (#20530)

Conrad Irwinad3171d16deb
diff --git a/crates/language_tools/src/key_context_view.rs b/crates/language_tools/src/key_context_view.rs
index 19f6de2a842..856660f9af5 100644
--- a/crates/language_tools/src/key_context_view.rs
+++ b/crates/language_tools/src/key_context_view.rs
@@ -4,6 +4,7 @@ use gpui::{
};
use itertools::Itertools;
use serde_json::json;
+use settings::get_key_equivalents;
use ui::{
div, h_flex, px, v_flex, ButtonCommon, Clickable, FluentBuilder, InteractiveElement, Label,
LabelCommon, LabelSize, ParentElement, SharedString, StatefulInteractiveElement, Styled,
@@ -167,6 +168,7 @@ impl Item for KeyContextView {
impl Render for KeyContextView {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl ui::IntoElement {
use itertools::Itertools;
+ let key_equivalents = get_key_equivalents(cx.keyboard_layout());
v_flex()
.id("key-context-view")
.overflow_scroll()
@@ -276,5 +278,17 @@ impl Render for KeyContextView {
}),
)
})
+ .when_some(key_equivalents, |el, key_equivalents| {
+ el.child(Label::new("Key Equivalents").mt_4().size(LabelSize::Large))
+ .child(Label::new("Shortcuts defined using some characters have been remapped so that shortcuts can be typed without holding option."))
+ .children(
+ key_equivalents
+ .iter()
+ .sorted()
+ .map(|(key, equivalent)| {
+ Label::new(format!("cmd-{} => cmd-{}", key, equivalent)).ml_8()
+ }),
+ )
+ })
}
}
diff --git a/crates/settings/src/settings.rs b/crates/settings/src/settings.rs
index a045f793b3c..de40cb7b2d3 100644
--- a/crates/settings/src/settings.rs
+++ b/crates/settings/src/settings.rs
@@ -12,6 +12,7 @@ use util::asset_str;
pub use editable_setting_control::*;
pub use json_schema::*;
+pub use key_equivalents::*;
pub use keymap_file::KeymapFile;
pub use settings_file::*;
pub use settings_store::{