Skip to content

Register console up/down history keybindings#13836

Open
juliasilge wants to merge 2 commits into
mainfrom
bugfix/console-history-navigation
Open

Register console up/down history keybindings#13836
juliasilge wants to merge 2 commits into
mainfrom
bugfix/console-history-navigation

Conversation

@juliasilge
Copy link
Copy Markdown
Member

Fixes #13419

The console's keyDownHandler in consoleInput.tsx currently intercepts arrow keys at the React layer before the keybinding service can see them. The UpArrow / DownArrow cases match on KeyCode alone, so Shift+Down and Shift+Up route to history navigation instead of falling through to cursorDownSelect / cursorUpSelect, breaking text selection.

This PR migrates Up/Down and Cmd/Ctrl+Up history navigation out of the React switch and into proper Action2 keybindings:

  • NavigateInputHistoryUp (Up)
  • NavigateInputHistoryDown (Down)
  • NavigateInputHistoryUpUsingPrefixMatch (Cmd/Ctrl+Up)

All three actions already existed (invokable from the Command Palette) but had no keybinding block. Adding the keybindings (a) fixes #13419 because Shift+Down no longer matches primary: KeyCode.DownArrow, letting the editor's cursorDownSelect win on weight, (b) surfaces the bindings in the Keyboard Shortcuts UI (addresses part of #7380), and (c) lets user-defined keybindings override them.

A new context key positronConsoleInputCursorBoundary (mirroring upstream's INTERACTIVE_INPUT_CURSOR_BOUNDARY) gates the keybindings so the action only fires when the cursor is at the appropriate boundary of the console input. Without this gate, the registered keybinding would steal Up/Down on interior lines of multi-line input.

This also fixes a pre-existing inconsistency where the prefix-match history browser was filtering by debug mode when invoked from Cmd/Ctrl+Up but not when invoked from the Command Palette. Both paths now filter consistently.

This is the first in a planned series of console keybinding migrations to address #7380 and related problems like #9500.

Release Notes

New Features

  • N/A

Bug Fixes

Validation Steps

@:console @:web @:win

New e2e regression tests cover the primary fixes:

  • 'Python - Shift+Down extends selection instead of navigating history'
  • 'Python - Cmd+Up engages prefix-match history browser'

Manual checks, for example during review:

  1. In an R or Python console, type some text on a single line. Place the cursor mid-text and press Shift+Down: the selection should extend to the end of the line, and typing should replace the selected text.
  2. Press Up and Down arrows with no modifiers: history navigation works as before.
  3. Type a prefix, press Cmd/Ctrl+Up: the prefix-match history browser engages, filtering to entries matching the prefix.
  4. With multi-line input (use Shift+Enter for the second line), place cursor on an interior line and press Up: cursor moves up within the input rather than triggering history navigation.
  5. With autocomplete visible, Up/Down should navigate suggestions, not history.
  6. Open the Keyboard Shortcuts UI and search "Navigate Input History": the three migrated actions display their bindings like so:
Screenshot 2026-05-27 at 8 37 51 PM

@github-actions
Copy link
Copy Markdown

E2E Tests 🚀
This PR will run tests tagged with: @:critical @:console @:web @:win

readme  valid tags

@juliasilge juliasilge marked this pull request as ready for review May 28, 2026 13:58
@juliasilge juliasilge requested a review from jmcphers May 28, 2026 13:59
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.

Shift+Down and Shift+Up in console trigger history navigation instead of extending text selection

1 participant