Fixes to Console and Variables keybindings #2864
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These fixes depend on each other so I gathered them in a single PR. Each commit can be cleanly reviewed separately though. Happy to split in multiple PRs if that would be preferred.
Fix shadowing of user keybindings
Addresses #2857.
The first commit improves the detection of extra modifiers in our keydown handlers for Console and Variables viewpanes. This allows unrelated commands to dispatch correctly, e.g. our Cmd+C handler will not prevent a user keybinding Shift+Cmd+C from running.
QA notes: The keys handled in these locations should still work as expected:
positron/src/vs/workbench/contrib/positronConsole/browser/components/consoleInstance.tsx
Line 342 in 2062523
positron/src/vs/workbench/contrib/positronConsole/browser/components/activityPrompt.tsx
Line 69 in 2062523
positron/src/vs/workbench/contrib/positronVariables/browser/components/variablesInstance.tsx
Line 152 in 2062523
In particular, typing text when the console is scrolled up should scroll all the way to the bottom, there should not be some pixels left to scroll.
Some of the keybindings such as for Copy, Cut, Paste, and Select all differ depending on the platform. MacOs uses the Cmd prefix key whereas other platforms use Ctrl.
Fix keybindings in foreign keyboard layouts
Addresses #2724.
The second commit changes our handlers to use the
key
field of keyboard events instead ofcode
fields. The former represents the character typed according to the user's keyboard layout. The latter represents the physical location on the keyboard, which doesn't match the layout.Restore cut command in console
Addresses #2549.
Third commit removes a registered keybinding for Cmd/Ctrl+X that was bound to an empty command. It was added in #1118, I assume to pair it with the context menu action for Cut. However removing it does not affect the context menu. And it turns out that the default Cut implementation pretty much does what we want:
Add paste handler to readline prompts
Addresses #2863.
Fourth commit implements select-all and paste in readline prompts. Paste is a quick stopgap implementation on top of the
<input>
HTML element. The direct HTML manipulation confuses undo/redo. I think we'd be better off using a VS Code code text editor that accepts text edits so that undo/redo work out of the box.