Skip to content
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

[JetBrains] Custom global key handler supporting Enter/Delete/Backspace and Enter+Shift in all IntelliJ IDEs flavors in the uniform way #7480

Merged
merged 8 commits into from
Mar 24, 2025

Conversation

PiotrKarczmarz
Copy link
Collaborator

@PiotrKarczmarz PiotrKarczmarz commented Mar 20, 2025

CLOSE https://linear.app/sourcegraph/issue/CODY-4704/backspace-and-enter-keys-not-working-in-rider-cody-window-macos

Special global handler for Backspace, Delete, Enter, and Shift+Enter which are not working properly in the CEF instance in Rider and potentially in other IntelliJ IDEs flavors. Even, when there are no shortcuts defined for these keys in the current keymap, press key events still aren't forwarded to the CEF instance, but looks like they are swallowed by other dispatchers (DefaultKeyboardFocusManager.keyEventDispatcher) in the pipeline:

image

The implementation un-consume a key event (via reflection), already consumed by other dispatchers, which allow a key event to be later handled by Cef component (webview).

Detecting the event source using JBCefOsrComponent type, which is about 30% faster than calling browser.uiComponent.hasFocus(), 2080.00 ns. vs 2923.53 ns. on average (handler is called for every keystroke, but the execution is narrowed only for JBCefOsrComponent to make minimal performance impact on IDE UI.

Test plan

  1. Run Rider
  2. Check if modifier keys are working in the Cody tool window:
    • Enter
    • Delete
    • Backspace
    • Enter + Shift

Copy link
Contributor

@pkukielka pkukielka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pkukielka pkukielka merged commit a275503 into main Mar 24, 2025
19 of 20 checks passed
@pkukielka pkukielka deleted the pkarczmarz/webview-shortcuts-handling-v2 branch March 24, 2025 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants