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

Lost text focus after "Ctrl-Enter" is pressed on jupyter notebook #6337

Closed
ws1088 opened this issue Jun 20, 2021 · 2 comments
Closed

Lost text focus after "Ctrl-Enter" is pressed on jupyter notebook #6337

ws1088 opened this issue Jun 20, 2021 · 2 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@ws1088
Copy link

ws1088 commented Jun 20, 2021

Environment data

  • VS Code version: 1.57
  • Jupyter Extension version (available under the Extensions sidebar): v2021.6.999406279
  • Python Extension version (available under the Extensions sidebar): v2021.6.944021595
  • OS (Windows | Mac | Linux distro) and version: Windows 10, Mac, and Linux
  • Python and/or Anaconda version: 3.7.4
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): virtualenv
  • Jupyter server running: Local and Remote

Expected behaviour

Should be like previous versions (before 1.57.0), when pressing "Ctrl-Enter" to run a cell, the text focus should remain in that some cell's text area, getting ready for users to add/change code and rerun.

Actual behaviour

Focus is lost

Steps to reproduce:

  1. open a jupyter notebook
  2. type print(1)
  3. press "Ctrl-Enter" to run the cell
@ws1088 ws1088 added the bug Issue identified by VS Code Team member as probable bug label Jun 20, 2021
@joyceerhl
Copy link
Contributor

joyceerhl commented Jun 21, 2021

@ws1088 The previous behavior where focus remains in the text editor after ctrl+enter was actually a bug, as reported by another user: #6198 We fixed this by contributing ctrl+enter tied to a custom command, jupyter.notebookeditor.keybind.executeCell.

You can go back to the old ctrl+enter behavior by opening the keyboard shortcuts configuration page:
image

And changing the keybinding for the following command to anything else:
image

@rchiodo rchiodo closed this as completed Jun 21, 2021
@ws1088
Copy link
Author

ws1088 commented Jun 22, 2021

thanks. it's interesting how different use cases consider something as a bug or not. personally i like ctrl-enter to remains in the cell focus because most of the time i would write some code and test it out. maybe 5% of the time when i press ctrl-enter i would want to loose focus.
I ended up removing jupyter.notebookeditor.keybind.executeCell and added back notebook.cell.execute to get back to pre-1.57.0 behavior:

    {
        "key": "ctrl+enter",
        "command": "-jupyter.notebookeditor.keybind.executeCell",
        "when": "config.jupyter.enableKeyboardShortcuts && notebookCellListFocused && notebookCellType == 'code' && notebookType == 'jupyter-notebook' || config.jupyter.enableKeyboardShortcuts && editorTextFocus && inputFocus && notebookEditorFocused && notebookType == 'jupyter-notebook'"
    },
    {
        "key": "ctrl+enter",
        "command": "notebook.cell.execute",
        "when": "notebookCellListFocused && notebookCellType == 'code' && notebookCellExecutionState == 'failed' || notebookCellExecutionState == 'idle' || notebookCellExecutionState == 'succeeded' && notebookKernelCount > 0"
    },

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 30, 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
Projects
None yet
Development

No branches or pull requests

4 participants