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

Attempt at Solving Rider's IDE keybindings issues #6887

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

arafatkatze
Copy link
Contributor

@arafatkatze arafatkatze commented Jan 30, 2025

Linear

Problem

The JetBrains IDE was intercepting certain keyboard events (backspace and shift+enter) in the Cody chat webview before they could reach the chat interface. This caused issues with:

  • Backspace not working properly for text deletion(Screenshot shows keymap specifically in rider ide that causes this behavior and removing that specific keymap solved it)
image
  • Shift+Enter not working for multi-line input
image

Solution

Added two action handlers that intercept these keyboard events before the IDE's default handlers:

  1. WebViewBackspaceAction - Intercepts backspace key events
  2. WebViewShiftEnterAction - Intercepts shift+enter key events

These actions do nothing when triggered, effectively preventing the IDE from handling these keys while allowing the events to bubble down naturally to the webview. This restores expected text editing behavior in the chat interface.

Implementation Details

  • Created empty action handlers that extend DumbAwareEDTAction
  • Registered keyboard shortcuts in plugin.xml for both default and Mac OS X keymaps
  • Actions are invisible in menus but still intercept keyboard events
  • Uses event bubbling to allow natural webview text handling

Test plan

NOTE: This test is not a perfect. guarantee because I can't replicate the issue in the debugger at all because debugger has some strangeness with the Keymaps(this is despite the fact that I built the rider plugin).

Verified that in the Cody chat webview:

  • Backspace properly deletes text
  • Shift+Enter creates new lines without triggering IDE actions

@arafatkatze arafatkatze requested a review from pkukielka January 30, 2025 16:10
@pkukielka
Copy link
Contributor

These actions do nothing when triggered, effectively preventing the IDE from handling these keys while allowing the events to bubble down naturally to the webview. This restores expected text editing behavior in the chat interface.

Is't that like overriding Rider shortcuts?
Are they still working for original Remove Selected Tests action in Rider? I do not see that in the testplan.
I think those actions should be only active if the webview component is focused.

@arafatkatze
Copy link
Contributor Author

Is't that like overriding Rider shortcuts?

Yes but only in the webview. We basically override Remove Selected Tests with a null. That's the intention

Are they still working for original Remove Selected Tests action in Rider? I do not see that in the testplan.

So in the test plan I couldn't make the best test plan because you can't replicate this error in the debugger so if you can't replicate the error then replicating that the solution works is also hard which is why the PR is titled "Attempt at Solving Rider's IDE keybindings". I do think this should ideally work but I am not 100% sure because I couldn't replicate the error in debugger even with Rider IDE.

One way I tested this was by running this in the debugger and doing backspaces in the webview and verified that my print statements were printed but only when I did backspace in webview and nowhere else.

I think those actions should be only active if the webview component is focused.

Yup I agree

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