vscode-jupyter icon indicating copy to clipboard operation
vscode-jupyter copied to clipboard

Cannot execute Run current cell for ~1s after I stop typing

Open chmielcode opened this issue 3 years ago • 7 comments

Applies To

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

What happened?

When I try to "Run current cell" just after I stop typing nothing happens.

To reproduce the problem place a new cell marker (#%%), start interactive window, wait for it to load, add another cell with any content...

#%%
1

...and finally press shift+enter (Jupyter: Run current cell) quickly (<~1s) after typing "1". It is enough to press backspace, type e.g. "2" and hit shift+enter to see it again.

Usually pressing shift+enter again after a small delay will work as intended, but sometimes it doesn't for another second or two or it sends whatever is before the current cursor position causing sytax errors.

To see the "whatever is before the current cursor position" behaviour repeat the steps mentioned above, but keep editing a string literal before pressing shift+enter.

#%%
"type here before pressing shift+enter"

I observe the same thing for small files with one cell only and large ones with thousands of lines of code and hunderds of cells. I tried to disable "Jupyter Keymap" extension and remove all other relevant "shift+enter" keybindings, but nothing worked.

It's been happening for a couple of weeks now and it's really hard for me to tell, which update (Python, Pylance, Jupyter or VSCode) introduced this bug. I encounter it multiple times every day and it forces me to read exception messages to find out whether it's my code's fault or I simply clicked shift+enter to quickly.

VS Code Version

1.66.2

Jupyter Extension Version

v2022.3.1000901801

Jupyter logs

Info 19:07:26: Adding hash for 46 = 2c93a441d4af with 1 lines
Info 19:07:26: Cancel all remaining cells true || Error || undefined
Info 19:07:26: Cancel pending cells
Info 19:07:26: Cell 46 executed with state Error

Coding Language and Runtime Version

Python 3.10.4

Language Extension Version (if applicable)

Python v2022.4.1

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Local

chmielcode avatar Apr 25 '22 17:04 chmielcode

Thanks for filing this issue. I'm unable to repro this at my end. Please could you capture a screen recording of this and upload it. You could try using gifcap.dev or the like to capture a gif.

DonJayamanne avatar Apr 25 '22 17:04 DonJayamanne

Recording 2022-04-25 at 20 18 14 I press shift+enter after I type "1" in each line in the first cell. With the second "1" I wasn't quick enough, so it actually executed the cell.

In the second cell i press shift+enter after every couple of characters (I hope you can see the short pauses) and then move the cursor a little bit to the left to get the unexpected syntax error.

chmielcode avatar Apr 25 '22 18:04 chmielcode

I have encountered this as well. I also have an issue which might be related where I need to execute higher up cells to proceed.

Recording2022-04-26at17 33 18

>>>python -VV
Python 3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:38:57) [GCC 10.3.0]
>>> code -v
1.66.2
dfd34e8260c270da74b5c2d86d61aee4b6d56977
x64
>>> code --list-extensions --show-versions | grep -E 'python|jupyter'
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

daylinmorgan avatar Apr 26 '22 22:04 daylinmorgan

I still can reproduce this bug with the latest release (Jupyter v2022.4.1001271738, VSCode 1.67).

About the unexpected syntax error after editing a string literal I've noticed, that just the last character is lost. Let's say I have already executed...

"""some  text"""

...then added "x" in the middle and quickly tried to execute the cell again.

"""some x text"""

The result will be:

  Input In [28]
    """some x text""
    ^
SyntaxError: incomplete input

So "" instead of """.

print("xx") -> print("xx"' etc.

chmielcode avatar May 05 '22 19:05 chmielcode

No change with current vscode/jupyter/python releases.

chmielcode avatar Jun 12 '22 17:06 chmielcode

@chmielcode Have you tried enabling code lens?

Seemingly with the code lens enable this isn't happening.

daylinmorgan avatar Jun 25 '22 16:06 daylinmorgan

@daylinmorgan Unfortunately I see no difference with code lens enabled.

  1. Type "abc", but not press shift+enter too quickly.
#%%
"abc"

'abc'

  1. Add space between b and c and immediately click shift+enter
#%%
"ab c"

Input In [2] "ab c ^ SyntaxError: unterminated string literal (detected at line 2)

chmielcode avatar Jun 26 '22 06:06 chmielcode

@chmielcode - are you still seeing this issue? No one on the team has experienced this but we can still try and look for race conditions that might cause this if it's still occurring

amunger avatar Dec 07 '22 23:12 amunger

@amunger yes, still the same.

chmielcode avatar Dec 08 '22 05:12 chmielcode