vscode: When "ctrl+enter" or "shift+enter" it run the wrong cell

Environment data

VS Code version: 1.60 Jupyter Extension version (available under the Extensions sidebar): v2021.8.1054968649 Python Extension version (available under the Extensions sidebar): v2021.7.1060902895 OS (Windows | Mac | Linux distro) and version: Windows 10: 21H1 Python and/or Anaconda version: 3.8.10/3.9.6 Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv Jupyter server running: Local | Remote | N/A: Local and remote

Expected behaviour

Run the selected cell when “ctrl+enter” or “shift+enter”.

Actual behaviour

Sometimes, when “ctrl+enter” or “shift+enter” to run a cell, it run the wrong cell. It seems to me that it is running the last cell ran.

Steps to reproduce:

Hard to reproduce as it is happening randomly. I would suspect it to happen after a high memory consumption (reaching to max) that will make it bug until we restart the apk/computer.

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

Logs

Output for Jupyter in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Jupyter)


About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 11
  • Comments: 33 (11 by maintainers)

Most upvoted comments

I think the problem is that vscode is not focusing on the current cell that’s being edited, the result of that is ctrl+enter runs the other cell that was wrongfully considered “current cell”

here is the gif

As can be seen from the gif, after editing the other 2 cells, the “current cell” with the blue bar is still the old one.

I don’t know how to trigger this, but it happens from time to time.

Having the same issue as well. It’s not a big issue as I can close and reopen the notebook to temporarily fix it, but it is annoying as hell.

This issue has been killing me. makes the vscode notebooks almost unusable. I generally resort to manually clicking the play button on a given cell to get it to run. This generally does not fix the behavior or change focus, but sometimes it does. Seems very stochastic overall.

@hamiddashti if this is the same problem I reported (https://github.com/microsoft/vscode/issues/136310) then a potential solution is to change focus from vscode to another application and then switch back. I noticed this as each time I encountered the issue I tried to switch to a screen recorder to record and the problem went away. It could well be a different issue though, or behave differently on different platforms (I’m using Linux)

I am still having this problem running on 1.62.3, Windows. It has been plaguing me for a while. The problem is intermittent and hard to reproduce in my case too. I have noticed that when it happens the thick blue ‘active cell’ line indicator (on left of cell) remains fixed on a certain cell, despite the creation or clicking on new cells. This is the cell that also executes, so I imagine the two are related. The cell toolbar also remains fixed on this cell despite focussing/clicking on a new cell in my case.

I have attached a screenshot here to better explain my descriptions. image

I’ve switched to insiders and haven’t had the problem again yet! I’ll message back again if it happens again in the insiders version.

Added detail: Often this seems to be caused by a clear separation of focus, where the blue vertical bar focus indicator is not on the cell currently being edited, as in the gif above.

However, at other times, the blue cell focus indicator is correct and a different cell is still run, with no visual indication of which one it will be.

Having the same issue, I’ve tried playing with the shortcuts, but I can’t seem to fix it. It really makes VSCode Notebooks unusable 😞

It seems like there’s some discrepancy with where the editor cursor is, and where the notebook thinks the cursor is when executing.