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

When no kernel is selected, notebook.cell.executeAndSelectBelow cell insertion dismisses kernel picker #128244

Closed
claudiaregio opened this issue Jul 3, 2021 · 6 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders notebook verified Verification succeeded
Milestone

Comments

@claudiaregio
Copy link

Environment data

  • VS Code version: 1.58.0-insider
  • Jupyter Extension version (available under the Extensions sidebar): v2021.8.993044620
  • Python Extension version (available under the Extensions sidebar): v2021.6.944021595
  • OS (Windows | Mac | Linux distro) and version: Windows

Steps to Reproduce:

  1. Create new notebook
  2. Put something in first cell
  3. Use Shift + Enter shortcut to run

Expected behavior

To be prompted for a kernel and run after selection, then focus moves to next cell

Actual behavior

Focus moves to the next cell, I am not prompted to pick a kernel as none is selected for a new notebook.
Have to put focus back on the first cell and try shift + enter again

*Note: This does not occur if I open an existing notebook that has not been seen by VS Code before

shift+enter first cell

@greazer greazer transferred this issue from microsoft/vscode-jupyter Jul 8, 2021
@greazer greazer transferred this issue from microsoft/vscode Jul 8, 2021
@greazer
Copy link
Contributor

greazer commented Jul 8, 2021

Let's take a look as we contribute shift-enter which just calls VS Code's command. It should popup the kernel.

@greazer greazer transferred this issue from microsoft/vscode-jupyter Jul 8, 2021
@joyceerhl
Copy link
Contributor

@claudiaregio I believe what's happening here is that the kernel picker comes up and then immediately disappears because the inserting a new cell into the notebook steals focus from the kernel picker. Can you confirm if that's what you're seeing too?

shift+enter keybinding maps directly to notebook.cell.executeAndSelectBelow, and if no kernel is selected the kernel picker should be appearing:

let kernel = this.getSelectedOrSuggestedKernel(notebook);
if (!kernel) {
await this._commandService.executeCommand(SELECT_KERNEL_ID);
kernel = this.getSelectedOrSuggestedKernel(notebook);
}

@joyceerhl joyceerhl changed the title Native Notebooks - Shift + Enter does not work on first cell of new notebook When no kernel is selected, notebook.cell.executeAndSelectBelow dismisses kernel picker and skips execution Jul 8, 2021
@joyceerhl joyceerhl changed the title When no kernel is selected, notebook.cell.executeAndSelectBelow dismisses kernel picker and skips execution When no kernel is selected, notebook.cell.executeAndSelectBelow cell insertion dismisses kernel picker Jul 8, 2021
@joyceerhl
Copy link
Contributor

The workspace edit to insert a new cell if the executed cell was the last one in the notebook dismisses the kernel picker. If there is already a cell below, focusing that cell doesn't dismiss the kernel picker.

That is why it looks like shift+enter doesn't work the first time: on first shift+enter, there is no cell below, so we insert a cell; if you set focus back to the first cell and try again, there's already a cell below, so it just focuses that one.

@joyceerhl
Copy link
Contributor

@roblourens I see that we intentionally defer evaluating runCell until after the next cell has been inserted (if necessary) and focused: #99156 Is there a way to ensure that inserting a notebook cell doesn't dismiss the kernel picker?

@claudiaregio
Copy link
Author

@joyceerhl Yes, I see a really fast flash

@roblourens roblourens added bug Issue identified by VS Code Team member as probable bug notebook labels Jul 13, 2021
@roblourens roblourens added this to the July 2021 milestone Jul 13, 2021
@JacksonKearl JacksonKearl added the verified Verification succeeded label Jul 29, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Aug 27, 2021
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 insiders-released Patch has been released in VS Code Insiders notebook verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

7 participants
@roblourens @rebornix @JacksonKearl @greazer @claudiaregio @joyceerhl and others