Repository navigation
apply custom editor keybindings to the console input - #18761
Conversation
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
left a comment
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
🟠 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.
There was a problem hiding this comment.
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.
RStudio E2E - all platforms1 test(s) failed
View / download the full reportView report online -- opens in the browser, no download needed. Available for 14 days. Download playwright-report.zip -- extract and open
All platforms - commit |
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.
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.
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
EditorCommandManagerpushes custom editor bindings to editors viaSetEditorCommandBindingsEvent(andResetEditorCommandsEventon reset), but onlyTextEditingTargetlistened for them. The console input is an Ace editor too, soShellPanenow 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:Any pre-existing
editor_bindings.jsonis set aside and restored through the R session. Passes locally in desktop-dev mode.Checklist