Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ctrl+Enter should go to Control mode immediately #6582

Closed
sfo opened this issue Jul 8, 2021 · 1 comment · Fixed by #6583
Closed

Ctrl+Enter should go to Control mode immediately #6582

sfo opened this issue Jul 8, 2021 · 1 comment · Fixed by #6583
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug notebook-commands

Comments

@sfo
Copy link

sfo commented Jul 8, 2021

There have been two discussions about loss of focus after hitting Ctrl+Enter in Edit mode within a cell: #6337 and #6198 .
However, the behavior is still faulty, compared to Jupyter Notebook / Lab.

Environment data

  • VS Code version: 1.58.0-insider
  • Jupyter Extension version (available under the Extensions sidebar): 2021.8.1007436305
  • Python Extension version (available under the Extensions sidebar): 2021.7.992362372-dev
  • OS (Windows | Mac | Linux distro) and version: Ubuntu 20.04.2
  • Python and/or Anaconda version: Python 3.9.5 / Conda 4.9.0
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Jupyter server running: Remote, but runs on localhost

Expected behaviour

Running a cell with Ctrl+Enter should switch to Control mode immediately, before actually executing the cell. After execution of the cell is finished, no mode or focus change should happen whatsoever.

Actual behaviour

Running a cell with Ctrl+Enter lets the cell stay in Edit mode until execution is completed. After execution is finished, it changes to Control mode. This also happens when switching focus to another cell to edit it during computation.

This is extremely frustrating when it leads to random commands being executed because one's in the middle of typing a line of code or navigating around in the cell.

Steps to reproduce:

  1. create a cell with a long running task, e.g.
import time
time.sleep(3)
  1. run the cell using Ctrl+Enter
  2. the cell stays in edit mode
  3. continue editing the cell or another cell while waiting for execution to finish
  4. as soon as the first cell finished execution, the mode is changed to Control mode.

Logs

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

Info 2021-07-08 08:47:50: Execute Cells request 1 0
Info 2021-07-08 08:47:50: Execute Cell 0 file:///home/stanley/Development/mwe/vscode/jupyter_cell_focus.ipynb
Info 2021-07-08 08:47:50: Cell Index:0, state:1, exec: 1. User queued cell for execution
Info 2021-07-08 08:47:50: Cell Index:0, state:1, exec: 1. Ready to execute
Info 2021-07-08 08:47:50: Cell Index:0, state:1, exec: 1. Before Execute individual cell
Info 2021-07-08 08:47:50: Cell Index:0, state:1, exec: 1. Start execution
Info 2021-07-08 08:47:51: Cell Index:0, state:3, exec: undefined. Send code for execution
Info 2021-07-08 08:47:51: Cell Index:0, state:3, exec: undefined. Wait for jupyter execution
Info 2021-07-08 08:47:51: �[32mWidget Coordinator sent IPyWidgets_mirror_execute
Info 2021-07-08 08:47:51: �[32mPosting message to Notebook UI 
Info 2021-07-08 08:47:51: �[32mWidget Coordinator received IPyWidgets_msg_received
Info 2021-07-08 08:47:51: �[32mWidget Coordinator sent IPyWidgets_msg
Info 2021-07-08 08:47:51: �[32mPosting message to Notebook UI 
Info 2021-07-08 08:47:51: Cell Index:0, state:3, exec: undefined. Kernel switching to busy
Info 2021-07-08 08:47:51: Notebook Session status file:///home/stanley/Development/mwe/vscode/jupyter_cell_focus.ipynb # Busy
Info 2021-07-08 08:47:51: Updating preferred kernel for remote notebook 5f553442-05de-4690-9161-ec150af9037c
Info 2021-07-08 08:47:51: Preferred kernel for file:///home/stanley/Development/mwe/vscode/jupyter_cell_focus.ipynb is 5f553442-05de-4690-9161-ec150af9037c
Info 2021-07-08 08:47:51: �[32mWidget Coordinator sent IPyWidgets_msg
Info 2021-07-08 08:47:51: �[32mPosting message to Notebook UI 
Info 2021-07-08 08:47:51: �[32mWidget Coordinator received IPyWidgets_msg_received
Info 2021-07-08 08:47:51: �[32mWidget Coordinator received IPyWidgets_iopub_msg_handled
Info 2021-07-08 08:47:51: �[32mWidget Coordinator received IPyWidgets_msg_received
Info 2021-07-08 08:47:51: �[32mWidget Coordinator received IPyWidgets_iopub_msg_handled
Info 2021-07-08 08:47:53: �[32mWidget Coordinator sent IPyWidgets_msg
Info 2021-07-08 08:47:53: �[32mPosting message to Notebook UI 
Info 2021-07-08 08:47:53: �[32mWidget Coordinator sent IPyWidgets_msg
Info 2021-07-08 08:47:53: �[32mPosting message to Notebook UI 
Info 2021-07-08 08:47:53: Cell Index:0, state:3, exec: 2. Kernel switching to idle
Info 2021-07-08 08:47:53: Cell Index:0, state:3, exec: 2. Jupyter execution completed
Info 2021-07-08 08:47:53: Cell Index:0, state:3, exec: 2. Completed successfully
Info 2021-07-08 08:47:53: Cell Index:0, state:3, exec: 2. Completed successfully & resolving
Info 2021-07-08 08:47:53: Notebook Session status file:///home/stanley/Development/mwe/vscode/jupyter_cell_focus.ipynb # Idle
Info 2021-07-08 08:47:53: Cell Index:0, state:3, exec: 2. After Execute individual cell 3
Info 2021-07-08 08:47:53: Cell Index:0, state:3, exec: 2. Executed successfully in executeCell
Info 2021-07-08 08:47:53: Updating preferred kernel for remote notebook 5f553442-05de-4690-9161-ec150af9037c
Info 2021-07-08 08:47:53: Preferred kernel for file:///home/stanley/Development/mwe/vscode/jupyter_cell_focus.ipynb is 5f553442-05de-4690-9161-ec150af9037c
Info 2021-07-08 08:47:53: Cell Index:0, state:3, exec: 2. Execution disposed
Info 2021-07-08 08:47:53: �[32mWidget Coordinator received IPyWidgets_msg_received
Info 2021-07-08 08:47:53: �[32mWidget Coordinator received IPyWidgets_msg_received
Info 2021-07-08 08:47:53: �[32mWidget Coordinator received IPyWidgets_iopub_msg_handled

@sfo sfo added the bug Issue identified by VS Code Team member as probable bug label Jul 8, 2021
joyceerhl added a commit that referenced this issue Jul 8, 2021
@joyceerhl joyceerhl assigned joyceerhl and unassigned DonJayamanne Jul 8, 2021
@joyceerhl
Copy link
Contributor

Thanks for filing a bug. This was an oversight in my implementation of ctrl+enter. Sorry for the trouble caused, should be fixed by Friday's Jupyter extension insiders build.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug notebook-commands
Projects
None yet
4 participants