Skip to content

Attempt at Solving Rider's IDE keybindings issues #6887

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

Closed
wants to merge 3 commits into 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

@pkukielka
Copy link
Contributor

pkukielka commented Feb 7, 2025

@arafatkatze

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

Looking at the code I do not see how that is happening only in the webview and not always? Could you please point me to a bit of code which is ensuring this is only happening for the webview?

So in the test plan I couldn't make the best test plan because you can't replicate this error in the debugger

You don't need debugger to test this though. Or do you mean it does not work with customRunIde in general?
Still, you can build the plugin and install it from disk in standalone IDE, it will work the same way as installed from the market.

@jdorfman
Copy link
Member

@arafatkatze any updates?

@arafatkatze
Copy link
Contributor Author

@jdorfman My understanding was that it was gonna be covered by others(@tomaszgolebiowski @PiotrKarczmarz )

@PiotrKarczmarz
Copy link
Collaborator

PiotrKarczmarz commented Feb 26, 2025

@jdorfman My understanding was that it was gonna be covered by others(@tomaszgolebiowski @PiotrKarczmarz )

I'm looking how to improve this solution and make it more universal across different IDEs, and more specially, between different keymaps used by users (the root cause why some keys/shortcuts aren't working in the webview - they are used by a current keymap and don't reach webview at all).

Copy link

This PR is marked as stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed automatically in 5 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants