vscode-jupyter: pressing arrow key when editing code cell sometimes doesn't work

Applies To

  • Notebooks (.ipynb files)
  • Interactive Window and/or Cell Scripts (.py files with #%% markers)

What happened?

Not sure how the issue is triggered, it just happened when using notebook:

  • arrow key doesn’t work anymore (typing still works)
  • up/down when “accross-the-cell” still works (from “frozen cell” to another cell)
  • change it to markdown then it works fine; then changing back arrow key again stops working;
  • pasting contents to a new cell - it depends on where the new cell is created, and seems is not related to the content itself.

I feel It’s possible that it’s because of other extensions. I will have a try disabling some.

Below is an illustration when I hold arrow down/up:

temp2

VS Code Version

1.77.0

Jupyter Extension Version

v2023.3.1000892223

Jupyter logs

(seems nothing related. the last lines are:)

info 16:49:35.053: Cancel all remaining cells true || Error || undefined
info 10:24:44.793: Cancel all remaining cells true || Error || undefined
info 10:29:40.538: Cancel all remaining cells true || Error || undefined
info 10:30:30.891: Cancel all remaining cells true || Error || undefined
info 10:30:39.537: Cancel all remaining cells true || Error || undefined

Coding Language and Runtime Version

No response

Language Extension Version (if applicable)

No response

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Remote

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 15
  • Comments: 55 (7 by maintainers)

Commits related to this issue

Most upvoted comments

I have been struggling with this problem for weeks, specifically in certain cells. Even after deleting and recreating those cells, the issue persisted in that particular cell, which was quite frustrating.

However, I found a workaround that seems to work. It involves hovering over a method in the affected cell, clicking in the documentation window, and then pressing the arrow keys. By doing so, the arrow keys start functioning properly.

I hope this solution proves helpful in your situation.

image

This issue still exists in 1.78

I figured out one way to reproduce this issue:

  • Hover on a variable
  • Click on the Hover (which makes it focused)
  • Enter, which focuses the cell container
  • Click on the Hover again, which will set editor selection
  • Move mouse away, Hover disappears, and then the arrow keys are stuck

https://github.com/microsoft/vscode-jupyter/assets/876920/0cc7497b-5578-4f1a-b110-a836ad096109

@aiday-mar we need to figure out how to update the context key in this scenario.

Please fix this, its incredibly annoying, I do not think this is a duplicate of https://github.com/microsoft/vscode-jupyter/issues/12738 since that describes moving between cells not moving the cursor within a cell.

You can run the command “Toggle keyboard shortcuts troubleshooting” to get some details on what is happening when you press the arrow key, and it might point you towards an extension or a bad context key

This issue should now be fixed in latest VS Code Insiders and will be available in next week’s Stable release. Thank you everyone for your patience and valuable troubleshooting tips.

Added two more (removal key binding rules) to manually fix this issue for Home and End keys. Likely need to do the same if you use CTRL+UP or CTRL+DOWN for keyboard navigation.

{ “key”: “home”, “command”: “-editor.action.goToTopHover”, “when”: “editorHoverFocused” }, { “key”: “end”, “command”: “-editor.action.goToBottomHover”, “when”: “editorHoverFocused” },

@briandw which keybindings did you remove?

Having same issue still in 1.78.1. Used suggestion by @lambertae to remove keybindings (for editor.action.scrollXHover) and it solved it for me. Here’s how I did it by removing the troublesome keybinding without modifying default keybindings:

  • Command > ‘Preferences: Open Keyboard Shortcuts (JSON)’
  • Added these four items (note the dash, ‘-’, before each command value.

{ “key”: “down”, “command”: “-editor.action.scrollDownHover”, “when”: “editorHoverFocused” }, { “key”: “left”, “command”: “-editor.action.scrollLeftHover”, “when”: “editorHoverFocused” }, { “key”: “right”, “command”: “-editor.action.scrollRightHover”, “when”: “editorHoverFocused” }, { “key”: “up”, “command”: “-editor.action.scrollUpHover”, “when”: “editorHoverFocused” },

Still happening here:

Version: 1.78.0 Commit: 252e5463d60e63238250799aef7375787f68b4ee Date: 2023-05-03T20:15:29.774Z Electron: 22.4.8 Chromium: 108.0.5359.215 Node.js: 16.17.1 V8: 10.8.168.25-electron.0 OS: Darwin arm64 22.4.0 Sandboxed: No

So the issue is marked ‘closed’, but the fix isn’t in the current stable release, and the time line for the next stable release version is unknown?

Thank you for your feedbacks. The fix was not shipped in 1.77.3 but is available in Insiders and also the next 1.78 stable.

I have the same problem, I don’t know how to replicate it, but apparently it happens to me sometime after using the “home” / “end” or “shift+home” / “shift+end” keys

VS Code Version

1.77.3

Jupyter Extension Version

v2023.3.1201040234

In the latest 1.78.1. This makes vs-code close to be unusable for notebooks. Also, this bug didn’t exist a few months ago.

Thank you all for the detailed reproduce steps and analysis. The arrow key is very hijacked by editor.action.scroll*Hover command whose context keys might not be updated properly. cc @aiday-mar

I have a workaround - Hover over a variable or a function and click on the hovered window press escape and arrows are back

Pressing Ctrl+K and Ctrl+I twice, to enter and exit hover mode, seems to work around this issue if you run into it. (or command+K, command+I on mac)

hi everybody, i got the the same issue, could you tell me how to fix this issue? I’m using the latest vs code insider version, but everything still has the same error

Do that! I hope it helps 😃

image

This is indeed an extremely annoying problem. It’s hard to believe that such basic functionality failure was allowed to go on for such a long time.

According to April 2023 Endgame #180716, 1.78 is expected to be released somewhere early next week (May 1-3).

For me left arrow resolves to this:

2023-04-19 15:46:39.117 [info] [KeybindingService]: | Resolving LeftArrow
2023-04-19 15:46:39.117 [info] [KeybindingService]: \ From 11 keybinding entries, matched editor.action.scrollLeftHover, when: editorHoverFocused, source: built-in.
2023-04-19 15:46:39.117 [info] [KeybindingService]: + Invoking command editor.action.scrollLeftHover.

instead of cursorLeft

I have a workaround - Hover over a variable or a function and click on the hovered window press escape and arrows are back

This worked for me. But as he said is a workaround. It would be nice if this behavior is fixed

Hi! I’m still facing this issue. VSCode Version: 1.78.2. Anyone could work their way around on mac? Thanks!

Yes try unbinding scroll hover as suggested above.

  • VSCode 1.78.2
  • Jupyter Extension v2023.4.1011241018

I face this issue/bug for 1~2 months.

glad to hear this is getting looked into! To add to the temporary fixes people already suggested I also added this to make the escape key work:

    { "key": "escape", "command": "-editor.action.escapeFocusHover", "when": "editorHoverFocused" },

changing the default setting is undesirable for such a fundamental feature (arrow keys in an editor).

nevertheless, please post the text of the above image.

@briandw which keybindings did you remove?

Having same issue still in 1.78.1. Used suggestion by @lambertae to remove keybindings (for editor.action.scrollXHover) and it solved it for me. Here’s how I did it by removing the troublesome keybinding without modifying default keybindings:

  • Command > ‘Preferences: Open Keyboard Shortcuts (JSON)’
  • Added these four items (note the dash, ‘-’, before each command value.

{ “key”: “down”, “command”: “-editor.action.scrollDownHover”, “when”: “editorHoverFocused” }, { “key”: “left”, “command”: “-editor.action.scrollLeftHover”, “when”: “editorHoverFocused” }, { “key”: “right”, “command”: “-editor.action.scrollRightHover”, “when”: “editorHoverFocused” }, { “key”: “up”, “command”: “-editor.action.scrollUpHover”, “when”: “editorHoverFocused” },

Thank you!

The problem is still happening, vscode 1.78.0

Same as @mapio and @Vulwsztyn on 1.78. Left, Right, Up, Down resolves in the degger to:

2023-05-06 16:58:43.405 [info] [KeybindingService]: / Soft dispatching keyboard event
2023-05-06 16:58:43.405 [info] [KeybindingService]: | Resolving [ArrowLeft]
2023-05-06 16:58:43.405 [info] [KeybindingService]: \ From 10 keybinding entries, matched editor.action.scrollLeftHover, when: editorHoverFocused, source: built-in.
2023-05-06 16:58:43.405 [info] [KeybindingService]: / Received  keydown event - modifiers: [], code: ArrowLeft, keyCode: 37, key: ArrowLeft
2023-05-06 16:58:43.406 [info] [KeybindingService]: | Converted keydown event - modifiers: [], code: ArrowLeft, keyCode: 15 ('LeftArrow')
2023-05-06 16:58:43.406 [info] [KeybindingService]: | Resolving [ArrowLeft]
2023-05-06 16:58:43.406 [info] [KeybindingService]: \ From 10 keybinding entries, matched editor.action.scrollLeftHover, when: editorHoverFocused, source: built-in.
2023-05-06 16:58:43.406 [info] [KeybindingService]: + Invoking command editor.action.scrollLeftHover.
2023-05-06 16:58:44.405 [info] [KeybindingService]: / Soft dispatching keyboard event
2023-05-06 16:58:44.405 [info] [KeybindingService]: | Resolving [ArrowRight]
2023-05-06 16:58:44.405 [info] [KeybindingService]: \ From 9 keybinding entries, matched editor.action.scrollRightHover, when: editorHoverFocused, source: built-in.
2023-05-06 16:58:44.406 [info] [KeybindingService]: / Received  keydown event - modifiers: [], code: ArrowRight, keyCode: 39, key: ArrowRight
2023-05-06 16:58:44.406 [info] [KeybindingService]: | Converted keydown event - modifiers: [], code: ArrowRight, keyCode: 17 ('RightArrow')
2023-05-06 16:58:44.406 [info] [KeybindingService]: | Resolving [ArrowRight]
2023-05-06 16:58:44.406 [info] [KeybindingService]: \ From 9 keybinding entries, matched editor.action.scrollRightHover, when: editorHoverFocused, source: built-in.
2023-05-06 16:58:44.406 [info] [KeybindingService]: + Invoking command editor.action.scrollRightHover.
2023-05-06 16:58:45.591 [info] [KeybindingService]: / Soft dispatching keyboard event
2023-05-06 16:58:45.591 [info] [KeybindingService]: | Resolving [ArrowUp]
2023-05-06 16:58:45.591 [info] [KeybindingService]: \ From 19 keybinding entries, matched editor.action.scrollUpHover, when: editorHoverFocused, source: built-in.
2023-05-06 16:58:45.591 [info] [KeybindingService]: / Received  keydown event - modifiers: [], code: ArrowUp, keyCode: 38, key: ArrowUp
2023-05-06 16:58:45.592 [info] [KeybindingService]: | Converted keydown event - modifiers: [], code: ArrowUp, keyCode: 16 ('UpArrow')
2023-05-06 16:58:45.592 [info] [KeybindingService]: | Resolving [ArrowUp]
2023-05-06 16:58:45.593 [info] [KeybindingService]: \ From 19 keybinding entries, matched editor.action.scrollUpHover, when: editorHoverFocused, source: built-in.
2023-05-06 16:58:45.593 [info] [KeybindingService]: + Invoking command editor.action.scrollUpHover.
2023-05-06 16:58:46.820 [info] [KeybindingService]: / Soft dispatching keyboard event
2023-05-06 16:58:46.820 [info] [KeybindingService]: | Resolving [ArrowDown]
2023-05-06 16:58:46.821 [info] [KeybindingService]: \ From 22 keybinding entries, matched editor.action.scrollDownHover, when: editorHoverFocused, source: built-in.
2023-05-06 16:58:46.821 [info] [KeybindingService]: / Received  keydown event - modifiers: [], code: ArrowDown, keyCode: 40, key: ArrowDown
2023-05-06 16:58:46.821 [info] [KeybindingService]: | Converted keydown event - modifiers: [], code: ArrowDown, keyCode: 18 ('DownArrow')
2023-05-06 16:58:46.821 [info] [KeybindingService]: | Resolving [ArrowDown]
2023-05-06 16:58:46.821 [info] [KeybindingService]: \ From 22 keybinding entries, matched editor.action.scrollDownHover, when: editorHoverFocused, source: built-in.
2023-05-06 16:58:46.821 [info] [KeybindingService]: + Invoking command editor.action.scrollDownHover.