Skip to content

apply custom editor keybindings to the console input - #18761

Merged
kevinushey merged 2 commits into
mainfrom
feature/console-editor-keybindings
Sep 10, 2026
Merged

kevinushey merged 2 commits into
mainfrom
feature/console-editor-keybindings

Conversation

@kevinushey

Copy link
Copy Markdown
Collaborator

Intent

Custom "Editor" keyboard shortcuts (Tools > Modify Keyboard Shortcuts) -- e.g. rebinding Remove Word Left to a different key -- now also apply to the Console input.

Fixes #12379.

Approach

EditorCommandManager pushes custom editor bindings to editors via SetEditorCommandBindingsEvent (and ResetEditorCommandsEvent on reset), but only TextEditingTarget listened for them. The console input is an Ace editor too, so ShellPane now subscribes to the same two events and applies them to its editor. Bindings loaded at startup follow the same event path, so a saved rebinding is honored by the console from the first prompt, with or without a source document open.

Testing

New Playwright test tests/panes/console/console_editor_keybindings.test.ts:

  • rebinds Remove Word Left through the real Modify Keyboard Shortcuts dialog, then checks the new shortcut deletes a word in the console input;
  • reloads the client and checks the saved rebinding is applied to the console at startup.

Any pre-existing editor_bindings.json is set aside and restored through the R session. Passes locally in desktop-dev mode.

Checklist

  • NEWS.md entry
  • e2e test

Custom "Editor" shortcuts (e.g. Remove Word Left) were only pushed to
source editing targets; the console's Ace editor never received the
SetEditorCommandBindingsEvent / ResetEditorCommandsEvent, so rebinding an
editor command had no effect in the console.

Addresses #12379

@gtritchie gtritchie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No blocking issues. 1 follow-up.

🟠 is real but not merge-blocking -- either address it here or open an issue to do so later.

  • 🟠 src/gwt/src/org/rstudio/studio/client/workbench/views/console/shell/ShellPane.java:57 -- resetting shortcuts also resets the Console's Home/End to visual-row navigation


events.addHandler(ResetEditorCommandsEvent.TYPE, event ->
{
editor.resetCommands();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🟠 After clicking Reset in Tools > Modify Keyboard Shortcuts, Home/End in the Console jump to the start/end of the visual row instead of the input line.

Re-apply editor.useDocumentLineNavigation() after editor.resetCommands().

Why

ShellWidget.java:146 calls input_.useDocumentLineNavigation(), which clones gotolinestart/gotolineend (and the select variants) with console-specific exec functions into the console editor's command manager. AceEditor.resetCommands() builds a fresh AceCommandManager and copies every default Ace command back over that manager, replacing those clones. Before this PR the console ignored ResetEditorCommandsEvent, so the overrides survived. It only affects a wrapped console line and clears on the next client reload.

The SetEditorCommandBindingsEvent path is not affected: AceCommandManager.rebindCommand clones the command already in the console's manager, keeping the override.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, and confirmed: resetCommands() re-adds every Ace default into the console's manager, clobbering the useDocumentLineNavigation() clones. Fixed in fbb7fd2 by re-applying the override after the reset. Also added an e2e case that resets through the dialog and checks Home/End still span a wrapped command; it fails without the fix.

@gtritchie gtritchie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Feedback posted

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

RStudio E2E - all platforms

1 test(s) failed

###################- 99% pass rate

Passed Failed Skipped Flaky
2685 1 188 9
Platform ✅ Passed ❌ Failed ⚠️ Skipped 🔁 Flaky
✅ auth-teardown 2 0 10 0
✅ desktop-linux 676 0 38 2
❌ desktop-macos 677 1 37 2
✅ desktop-windows 678 0 39 5
✅ server-linux 624 0 44 0
✅ setup 28 0 20 0
View / download the full report

View report online -- opens in the browser, no download needed. Available for 14 days.

Download playwright-report.zip -- extract and open index.html

Includes screenshots, traces, and step-by-step details for every test. Expires in 15 days.


All platforms - commit fbb7fd28e350e3815b4bd23f8921366d9eb06b29 - Run #927

resetCommands() reinstalls every Ace default in the console's command
manager, which replaced the whole-line Home / End commands installed by
ShellWidget. Re-apply them after the reset, and cover the reset path in
the e2e test.
@kevinushey
kevinushey merged commit 6b76177 into main Sep 10, 2026
35 of 36 checks passed
@kevinushey
kevinushey deleted the feature/console-editor-keybindings branch September 10, 2026 23:19
gtritchie added a commit that referenced this pull request Sep 12, 2026
Cherry-picked from af7ab6b (#18789) on main. That commit hardened five
specs; the console-keybindings one is dropped here because its feature
(#18761, custom editor keybindings in the console) is not on this branch,
so neither is the spec.

- resetToUntitled kept a DIRTY untitled placeholder. The placeholder is
  shared across specs, so text a previous spec left in it survived the
  reset; the next saveAllSourceDocs then raised a modal Save File prompt
  for the pathless doc, and its glass panel blocked the console.
  SourceColumnManager now only reuses a clean untitled doc,
  waitForSourcePaneReset requires one, and closeSourceAndDeleteFile drops
  the saveAllSourceDocs it never needed.

- closeProjectIfOpen could sit behind "Save workspace image?".
  ApplicationQuit's saveAction_ holds its saveAsk() default until the
  backend's SaveActionChangedEvent lands, so a project closed seconds
  after it opened prompts anyway. Dismiss it.

- The vimrc mid-session spec clicked the editor straight after
  newSourceDoc, so the click landed on the outgoing document's unrendered
  ace_content. Wait for the new editor.

- The ghost-text specs treated "No completions available" as something to
  wait out. It is terminal, so a declined suggestion cost the full 30s
  budget. Re-request instead.

Adds source_pane_reset.test.ts, which fails without the
SourceColumnManager change.

This branch was previously deployed

1 inactive deployment
e2e-playwright — fbb7fd28 Deployed Sep 10, 2026 by kevinushey via windows / e2e-desktop-windows (6) #927
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.

Add "Remove Word Left" to the keybindings of the console as well

2 participants