macos: Fix an issue with chorded keys in norwegian keymap

fixes: https://github.com/wez/wezterm/issues/151
This commit is contained in:
Wez Furlong committed 2020-02-12 18:36:05 -08:00
1 parent c95215b057
commit 02ace26e0a
1 file changed
+26 -4
+26 -4
View File
@@ -1029,6 +1029,14 @@ impl WindowView {
let modifiers = unsafe { key_modifiers(nsevent.modifierFlags()) };
let virtual_key = unsafe { nsevent.keyCode() };
log::debug!(
"key_common: chars=`{}` unmod=`{}` modifiers=`{:?}` virtual_key={:?}",
chars.escape_debug(),
unmod.escape_debug(),
modifiers,
virtual_key
);
// `Delete` on macos is really Backspace and emits BS.
// `Fn-Delete` emits DEL.
// Alt-Delete is mapped by the IME to be equivalent to Fn-Delete.
@@ -1045,6 +1053,19 @@ impl WindowView {
unmod
};
// If unmod is empty it most likely means that the user has selected
// an alternate keymap that has a chorded representation of eg: an ASCII
// character. One example of this is selecting a Norwegian keymap on
// a US keyboard. The `~` symbol is produced by pressing CTRL-].
// That shows up here as unmod=`` with modifiers=CTRL. In this situation
// we want to cancel the modifiers out so that we just focus on
// `chars` instead.
let modifiers = if unmod.is_empty() {
Modifiers::NONE
} else {
modifiers
};
if USE_IME.load(Ordering::Relaxed) && modifiers.is_empty() {
unsafe {
let input_context: id = msg_send![this, inputContext];
@@ -1089,12 +1110,13 @@ impl WindowView {
key_is_down,
};
/*
eprintln!(
log::debug!(
"key_common {:?} (chars={:?} unmod={:?} modifiers={:?}",
event, chars, unmod, modifiers
event,
chars,
unmod,
modifiers
);
*/
if let Some(myself) = Self::get_this(this) {
let mut inner = myself.inner.borrow_mut();