microsoft / vscode-jupyter

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

Shift+Enter to run cell doesn't work frequently when first running python interactive in a new project #3347

Closed AeneasZhu closed 4 years ago

AeneasZhu commented 5 years ago

When I press Shift+Enter or Ctrl+Enter to run a cell in python jupyter (not the python interactive window one) in a new project, it doesn't and I have to click the "run cell" on my own to run the cell

image

greazer commented 5 years ago

@AeneasZhu, can you confirm that what you're saying is that, you open a python file with cells, then in one of the cells you press shift-enter. The interactive window doesn't start? Or something else? You can only get out of this situation by running via the "Run Cell" codelens?

AeneasZhu commented 5 years ago

@AeneasZhu, can you confirm that what you're saying is that, you open a python file with cells, then in one of the cells you press shift-enter. The interactive window doesn't start? Or something else? You can only get out of this situation by running via the "Run Cell" codelens?

Kind of. I mean, when I create a py file in a new created folder with 'cells', and press 'shift+enter' or 'ctrl + enter', the interactive window just reads the line where the cursor is, not the whole cell.

rchiodo commented 5 years ago

This happens for me too.

Only the line with the cursor is run.

AeneasZhu commented 5 years ago

This happens for me too.

  • Create new folder
  • Create new py file
  • Add a cell with two lines in it
  • Shift+Enter

Only the line with the cursor is run.

Is it a bug?

rchiodo commented 5 years ago

Yes I believe so.

AeneasZhu commented 5 years ago

Yes I believe so.

Can it be dealt with in the next update?

rchiodo commented 5 years ago

It likely will be. We assign labels and pipelines to bugs. This one is a P1 in the backlog meaning it should be dealt with before our next release.

radu-b commented 5 years ago

It still happens in 2019.6.24221, pretty much all the time, not just on new files but also on existing ones. Sometimes it starts working (i.e. running the current cell) after several attempts, or after running code manually in the interactive window; sometimes it just keeps running only the current line without advancing the pointer.

The issue doesn't happen in the last 2019.5 version (or if it does, it's quite rare), so I have to stick to that version.

I'm on Ubuntu 18.04, VS Code 1.36.1.

rchiodo commented 5 years ago

@radu-b do you have the code lens at the top of each cell when this is happening?

Does it happen if you reload vscode?

AeneasZhu commented 5 years ago

It still happens in 2019.6.24221, pretty much all the time, not just on new files but also on existing ones. Sometimes it starts working (i.e. running the current cell) after several attempts, or after running code manually in the interactive window; sometimes it just keeps running only the current line without advancing the pointer.

The issue doesn't happen in the last 2019.5 version (or if it does, it's quite rare), so I have to stick to that version.

I'm on Ubuntu 18.04, VS Code 1.36.1.

I think I have solved this problem in some way. Once you open the Interative Window, you shall click the right side(where the interative window is) once, and the shift+enter shall work. I don't know why, but I just found it

radu-b commented 5 years ago

@rchiodo no, I had the code lens hidden. I've tried again with it visible, and the issue doesn't happen. It only occurs with the code lens hidden. Restarting makes no difference.

I can confirm AeneasZhu's comment above, clicking the interactive input solves the problem even with the code lens hidden.

rchiodo commented 5 years ago

Ah having the code lens hidden makes sense. It looks like the code doesn't activate the right context unless code lens are active.