Skip to content

Commit c3c5404

Browse files
committed
fix
1 parent 459f168 commit c3c5404

File tree

6 files changed

+19
-1428
lines changed

6 files changed

+19
-1428
lines changed

crates/gpui/src/platform/keyboard.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use collections::HashMap;
2+
13
use crate::{KeybindingKeystroke, Keystroke};
24

35
/// A trait for platform-specific keyboard layouts
@@ -16,6 +18,9 @@ pub trait PlatformKeyboardMapper {
1618
keystroke: Keystroke,
1719
use_key_equivalents: bool,
1820
) -> KeybindingKeystroke;
21+
/// Get the key equivalents for the current keyboard layout,
22+
/// only used on macOS
23+
fn get_key_equivalents(&self) -> Option<&HashMap<char, char>>;
1924
}
2025

2126
/// A dummy implementation of the platform keyboard mapper
@@ -29,4 +34,8 @@ impl PlatformKeyboardMapper for DummyKeyboardMapper {
2934
) -> KeybindingKeystroke {
3035
KeybindingKeystroke::from_keystroke(keystroke)
3136
}
37+
38+
fn get_key_equivalents(&self) -> Option<&HashMap<char, char>> {
39+
None
40+
}
3241
}

crates/gpui/src/platform/mac/keyboard.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ impl PlatformKeyboardMapper for MacKeyboardMapper {
4444
}
4545
KeybindingKeystroke::from_keystroke(keystroke)
4646
}
47+
48+
fn get_key_equivalents(&self) -> Option<&HashMap<char, char>> {
49+
self.key_equivalents.as_ref()
50+
}
4751
}
4852

4953
impl MacKeyboardLayout {

crates/gpui/src/platform/windows/keyboard.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ impl PlatformKeyboardMapper for WindowsKeyboardMapper {
8989
display_key: key,
9090
}
9191
}
92+
93+
fn get_key_equivalents(&self) -> Option<&HashMap<char, char>> {
94+
None
95+
}
9296
}
9397

9498
impl WindowsKeyboardLayout {

crates/language_tools/src/key_context_view.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use gpui::{
44
};
55
use itertools::Itertools;
66
use serde_json::json;
7-
use settings::get_key_equivalents;
87
use ui::{Button, ButtonStyle};
98
use ui::{
109
ButtonCommon, Clickable, Context, FluentBuilder, InteractiveElement, Label, LabelCommon,
@@ -169,7 +168,8 @@ impl Item for KeyContextView {
169168
impl Render for KeyContextView {
170169
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl ui::IntoElement {
171170
use itertools::Itertools;
172-
let key_equivalents = get_key_equivalents(cx.keyboard_layout().id());
171+
172+
let key_equivalents = cx.keyboard_mapper().get_key_equivalents();
173173
v_flex()
174174
.id("key-context-view")
175175
.overflow_scroll()

0 commit comments

Comments
 (0)