History

linux: Don't insert characters if modifiers other than shift are held (#33424)

Closes #32219 #29666 Release Notes: - Linux: Now skips insertion of characters when modifiers are held. Before, characters were inserted if there's no match in the keymap.

Michael Sloan committed 1 year ago

Commit dfdeb1b1 parent b9f81c72 files · +18 −13Browse files

Unified · Split

2 files
  1. crates/gpui/src/platform/linux/wayland/window.rs +8 −6
  2. crates/gpui/src/platform/linux/x11/window.rs +10 −7
crates/gpui/src/platform/linux/wayland/window.rs+8−6
@@ -699,12 +699,14 @@ impl WaylandWindowStatePtr { · 698 unmodified lines
699 }699 }
700 }700 }
701 if let PlatformInput::KeyDown(event) = input {701 if let PlatformInput::KeyDown(event) = input {
702 if let Some(key_char) = &event.keystroke.key_char {702 if event.keystroke.modifiers.is_subset_of(&Modifiers::shift()) {
703 let mut state = self.state.borrow_mut();703 if let Some(key_char) = &event.keystroke.key_char {
704 if let Some(mut input_handler) = state.input_handler.take() {704 let mut state = self.state.borrow_mut();
705 drop(state);705 if let Some(mut input_handler) = state.input_handler.take() {
706 input_handler.replace_text_in_range(None, key_char);706 drop(state);
707 self.state.borrow_mut().input_handler = Some(input_handler);707 input_handler.replace_text_in_range(None, key_char);
708 self.state.borrow_mut().input_handler = Some(input_handler);
709 }
708 }710 }
709 }711 }
710 }712 }
crates/gpui/src/platform/linux/x11/window.rs+10−7
@@ -982,14 +982,17 @@ impl X11WindowStatePtr { · 981 unmodified lines
982 }982 }
983 }983 }
984 if let PlatformInput::KeyDown(event) = input {984 if let PlatformInput::KeyDown(event) = input {
985 let mut state = self.state.borrow_mut();985 // only allow shift modifier when inserting text
986 if let Some(mut input_handler) = state.input_handler.take() {986 if event.keystroke.modifiers.is_subset_of(&Modifiers::shift()) {
987 if let Some(key_char) = &event.keystroke.key_char {987 let mut state = self.state.borrow_mut();
988 drop(state);988 if let Some(mut input_handler) = state.input_handler.take() {
989 input_handler.replace_text_in_range(None, key_char);989 if let Some(key_char) = &event.keystroke.key_char {
990 state = self.state.borrow_mut();990 drop(state);
991 input_handler.replace_text_in_range(None, key_char);
992 state = self.state.borrow_mut();
993 }
994 state.input_handler = Some(input_handler);
991 }995 }
992 state.input_handler = Some(input_handler);
993 }996 }
994 }997 }
995 }998 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t