-
-
Notifications
You must be signed in to change notification settings - Fork 49
+semver:minor Added KeysExtensions class with the IsNavigationKey ext… #1437
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…ension method. Fixed a subtle bug in IbusKeyboardSwitchingAdaptor when determining whether IBus would have handled a key event while a pre-edit is active. The code now accounts for the possibility of modifier keys (particularly Ctrl), which IBus would presumably have handled when in combination with navigation keys, Backspace, and Delete.
// If IBus handled the key we don't want the control to get it. However, | ||
// we can't do this in PreviewKeyDown, so we temporarily subscribe to | ||
// KeyDown and suppress the key event there. | ||
control.KeyDown += HandleKeyDownAfterIbusHandledKey; |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null Warning
control
this
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 days ago
To fix the issue, we need to ensure that control
is not null
before it is dereferenced on line 313. This can be achieved by adding a null check for control
after it is assigned on line 286. If control
is null
, the method should return early, as further operations depend on control
being valid.
This fix ensures that the method behaves safely even if sender
is not of type Control
, preventing a potential NullReferenceException
.
-
Copy modified lines R287-R288
@@ -286,2 +286,4 @@ | ||
var control = sender as Control; | ||
if (control == null) | ||
return; | ||
var eventHandler = GetEventHandlerForControl(control); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
### Fixed | ||
|
||
- [SIL.Windows.Kwyboarding] Fixed a subtle bug in IbusKeyboardSwitchingAdaptor when determining whether IBus would have handled a key event while a pre-edit is active. The code now accounts for the possibility of modifier keys (particularly Ctrl), which IBus would presumably have handled when in combination with navigation keys, Backspace, and Delete. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- [SIL.Windows.Kwyboarding] Fixed a subtle bug in IbusKeyboardSwitchingAdaptor when determining whether IBus would have handled a key event while a pre-edit is active. The code now accounts for the possibility of modifier keys (particularly Ctrl), which IBus would presumably have handled when in combination with navigation keys, Backspace, and Delete. | |
- [SIL.Windows.Keyboarding] Fixed a subtle bug in IbusKeyboardSwitchingAdaptor when determining whether IBus would have handled a key event while a pre-edit is active. The code now accounts for the possibility of modifier keys (particularly Ctrl), which IBus would presumably have handled when in combination with navigation keys, Backspace, and Delete. |
/// REVIEW: During pre-edit, I assume that IBus handles both basic and modified navigation | ||
/// keys like Ctrl+Left. ChatGPT says this is true, but I have not been able to verify this | ||
/// since I don't know how to set up a Linux/IBus environment where I could test this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To test this on Linux:
- install Ubuntu 24.04 in a VM
- install an IME that uses pre-edit: in a terminal run
sudo apt update && sudo apt install ibus-pinyin
- open Keyboard settings, click "+ Add Input Source", search for Pinyin by clicking on the three dots below English. If you type the search term "pinyin" you'll get "Other". Clicking that shows "Chinese (Pinyin)" which you then can add.
- close the settings
- in the terminal run
ibus restart
(or reboot) - the language/keyboard picker in the top bar should now show "Chinese (Pinyin)".
…ension method.
Fixed a subtle bug in IbusKeyboardSwitchingAdaptor when determining whether IBus would have handled a key event while a pre-edit is active. The code now accounts for the possibility of modifier keys (particularly Ctrl), which IBus would presumably have handled when in combination with navigation keys, Backspace, and Delete.
This change is