microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.3k stars 292 forks source link

shift + enter to execute code in the REPL broken #16010

Closed rgbmrc closed 2 months ago

rgbmrc commented 2 months ago

Applies To

What happened?

Since the last update of vscode and the jupter extension, shift+enter keyboard bindings do no longer work as expected. When an interactive window is launched by executing some cells of some script_with_cells.py (on the side), pressing shift+enter (*) to execute a command directly from the input box of the interactive window does not work.

source

The Keyboard Shortcuts Troubleshooting suggests (logs below) this is due to ms-toolsai.jupyter.runcurrentcelladvance taking precedence over vscode's interactive.execute.

workaround

A workaround seem to be adding activeEditor != 'workbench.editor.interactive' to the "when" conditions of runcurrentcelladvance.

setup

(*) I have "interactiveWindow.executeWithShiftEnter" set to true in vscode. All my shift+enter keybindings are set to the default and managed by (source) either: system, the python extension, or the jupyter/jupyter keymap extensions.

VS Code Version

Version: 1.93.0 (user setup) Commit: 4849ca9bdf9666755eb463db297b69e5385090e3 Date: 2024-09-04T13:02:38.431Z Electron: 30.4.0 ElectronBuildId: 10073054 Chromium: 124.0.6367.243 Node.js: 20.15.1 V8: 12.4.254.20-electron.0 OS: Windows_NT x64 10.0.22631

Jupyter Extension Version

v2024.8.0

Jupyter logs

no output from "Jupyter Show Output" but I think the issue is still relevant to the jupyter extension since it relates to its settings

here is the output from vscode's "Window" after turning on "Developer: Toggle Keyboard Shortcuts Troubleshooting"

>>> with script_with_cells.py open on the side (cursor focus on interactive editor's input box)

2024-09-07 16:46:56.104 [info] [KeybindingService]: / Soft dispatching keyboard event
2024-09-07 16:46:56.104 [info] [KeybindingService]: \ Keyboard event cannot be dispatched
2024-09-07 16:46:56.104 [info] [KeybindingService]: / Received  keydown event - modifiers: [shift], code: ShiftRight, keyCode: 16, key: Shift
2024-09-07 16:46:56.104 [info] [KeybindingService]: | Converted keydown event - modifiers: [shift], code: ShiftRight, keyCode: 4 ('Shift')
2024-09-07 16:46:56.104 [info] [KeybindingService]: \ Keyboard event cannot be dispatched in keydown phase.
2024-09-07 16:46:56.351 [info] [KeybindingService]: / Soft dispatching keyboard event
2024-09-07 16:46:56.352 [info] [KeybindingService]: | Resolving shift+Enter
2024-09-07 16:46:56.352 [info] [KeybindingService]: \ From 16 keybinding entries, matched jupyter.runcurrentcelladvance, when: editorTextFocus && isWorkspaceTrusted && jupyter.hascodecells && !editorHasSelection && !notebookEditorFocused, source: user extension ms-toolsai.jupyter.
2024-09-07 16:46:56.352 [info] [KeybindingService]: / Received  keydown event - modifiers: [shift], code: Enter, keyCode: 13, key: Enter
2024-09-07 16:46:56.352 [info] [KeybindingService]: | Converted keydown event - modifiers: [shift], code: Enter, keyCode: 3 ('Enter')
2024-09-07 16:46:56.352 [info] [KeybindingService]: | Resolving shift+Enter

2024-09-07 16:46:56.352 [info] [KeybindingService]: \ From 16 keybinding entries, matched jupyter.runcurrentcelladvance, when: editorTextFocus && isWorkspaceTrusted && jupyter.hascodecells && !editorHasSelection && !notebookEditorFocused, source: user extension ms-toolsai.jupyter.
2024-09-07 16:46:56.352 [info] [KeybindingService]: + Invoking command jupyter.runcurrentcelladvance.
2024-09-07 16:46:56.439 [info] [KeybindingService]: + Ignoring single modifier shift due to it being pressed together with other keys.

>>> with another tab on the side panel (script_with_cells.py open but not visible, focus as above)

2024-09-07 16:44:43.435 [info] [KeybindingService]: / Soft dispatching keyboard event
2024-09-07 16:44:43.436 [info] [KeybindingService]: \ Keyboard event cannot be dispatched
2024-09-07 16:44:43.437 [info] [KeybindingService]: / Received  keydown event - modifiers: [shift], code: ShiftRight, keyCode: 16, key: Shift
2024-09-07 16:44:43.437 [info] [KeybindingService]: | Converted keydown event - modifiers: [shift], code: ShiftRight, keyCode: 4 ('Shift')
2024-09-07 16:44:43.438 [info] [KeybindingService]: \ Keyboard event cannot be dispatched in keydown phase.
2024-09-07 16:44:43.480 [info] [KeybindingService]: / Soft dispatching keyboard event
2024-09-07 16:44:43.481 [info] [KeybindingService]: | Resolving shift+Enter
2024-09-07 16:44:43.481 [info] [KeybindingService]: \ From 16 keybinding entries, matched interactive.execute, when: config.interactiveWindow.executeWithShiftEnter && activeEditor == 'workbench.editor.interactive', source: built-in.
2024-09-07 16:44:43.481 [info] [KeybindingService]: / Received  keydown event - modifiers: [shift], code: Enter, keyCode: 13, key: Enter
2024-09-07 16:44:43.481 [info] [KeybindingService]: | Converted keydown event - modifiers: [shift], code: Enter, keyCode: 3 ('Enter')
2024-09-07 16:44:43.481 [info] [KeybindingService]: | Resolving shift+Enter

2024-09-07 16:44:43.481 [info] [KeybindingService]: \ From 16 keybinding entries, matched interactive.execute, when: config.interactiveWindow.executeWithShiftEnter && activeEditor == 'workbench.editor.interactive', source: built-in.
2024-09-07 16:44:43.481 [info] [KeybindingService]: + Invoking command interactive.execute.
2024-09-07 16:44:43.552 [info] [KeybindingService]: + Ignoring single modifier shift due to it being pressed together with other keys.

Coding Language and Runtime Version

Python 3.11.9

Language Extension Version (if applicable)

v2024.14.0

Anaconda Version (if applicable)

conda 23.7.4

Running Jupyter locally or remotely?

Remote

amunger commented 2 months ago

regression from https://github.com/microsoft/vscode-jupyter/commit/1515b12e823afbfeb9df7e503e9a85999a2fd347

amunger commented 2 months ago

this should now be fixed in release.