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

Shift+Enter on a file with cells always sends the entire cell even if code is selected #3625

Closed
rchiodo opened this issue Feb 14, 2019 · 19 comments
Assignees

Comments

@rchiodo
Copy link
Contributor

rchiodo commented Feb 14, 2019

On a file without cells, Shift+Enter runs the current line or the selection.

On a file with cells, it should run the current cell, or the selection. It doesn't run the selection.

@IanMatthewHuff
Copy link
Member

When I added the shift-enter re-rerouting I only dealt with the .py files with no cells. Since those were the cells that conflicted with terminal. But the with cells case the previous logic (shift-enter = run this cell) is still winning out. Run cell should only run if there is no selection.

@FranciscoRZ
Copy link

Hello,
I'm having a similar issue where shift + enter exclusively sends to the Python terminal instead of the notebook. I've looked around to see if it's a config issue on my part and haven't found anything about VSCode's jupyter support other than just importing the notebook and pressing shift+enter.
Maybe it's a bug?

@IanMatthewHuff
Copy link
Member

Hey @FranciscoRZ you are able to start and run the notebook normally? Our shift-enter prompt should come up if you have a valid jupyter install and ask you one time if you want to send shift-enter to our window instead of the terminal.

@IanMatthewHuff
Copy link
Member

If you want to force this, there is a setting:
Python>Data Science: Send Selection To Interactive Window.
That way even without the popup you can get the same effect.

@FranciscoRZ
Copy link

FranciscoRZ commented Feb 15, 2019 via email

@FranciscoRZ
Copy link

FranciscoRZ commented Feb 15, 2019 via email

@IanMatthewHuff
Copy link
Member

No problem, if there are still any issues with it just give me a ping back here and I'll look into it.

@ronglums
Copy link
Contributor

Also, please add more logging for webview startup.

@FranciscoRZ
Copy link

FranciscoRZ commented Feb 18, 2019

@IanMatthewHuff, left an answer on StackOverflow. Thanks again for taking an interest! (And sorry for the delay in answering, I forgot it was Friday last week and I wasn't coming to the office on Saturday 😆 )

@FranciscoRZ
Copy link

@IanMatthewHuff, I really don't understand what's happening. I just downloaded the insiders build and still don't have the option (in Command Palette Open Settings (UI)) you spoke of, nor the pop-up.
Exact steps:

  • Dowload insider build
  • Lauch Anaconda Prompt
  • cd {projectFolder}/.ipynb_checkpoints
  • conda activate {myEnv}
  • code-insiders .
  • From Code, open {fileName}.ipynb, import Jupyter Notebook
  • Command Palette: >python: Show Python Interactive Window
  • In Untitled-1.py, write print('Hello, World') then select code and press shift+enter

Expected: sends to Python Interactive window
Actual: creates new Python terminal, deactivates conda env, reactivates same conda env, sends print('Hello, World') to created terminal

@IanMatthewHuff
Copy link
Member

@FranciscoRZ My apologies. I led you wrong here. Very sorry about that.
This code has been added (and the setting exists) but it's not yet in the public shipping version of our extension. When you mentioned insiders builds I thought that you meant the preview / dev build of our extension. But you would not yet see this fix in VSCode or VSCode - Insiders as those would both still be using our most recent public extension.

For this fix you'd need to either wait for the February release (which should be coming along pretty soon now) or you can take a peek at our current development build here:
https://github.com/Microsoft/vscode-python/blob/master/CONTRIBUTING.md#development-build

Sorry about your time looking into that.

@FranciscoRZ
Copy link

FranciscoRZ commented Feb 21, 2019

Thanks for the helpful answer!
I'll wait for the release to make the installation is stable.
Just out of curiosity, what's the difference between the VS Code Insiders and the development build?
I thought that's exactly what Insiders was 😅

@IanMatthewHuff
Copy link
Member

@FranciscoRZ Yeah, so it is a bit confusing regarding that. Basically extensions (even the Microsoft provided ones) are all separate from VSCode core. VSCode - Insiders represents a development build of VSCode core only, all the extensions that you have installed would just be the normal public version of each extension. So if you have VSCode and VSCode - Insiders installed the extensions for both will all just be the same public versions. You have to update extensions specifically if you want pre-release versions of them (and not all extensions even provide pre-release versions).

@FranciscoRZ
Copy link

Oh right, forgot about the nuance.
Anyways, thanks for taking the time! I'm a big fan of what you guys are doing. Coming from a C# dev background to Python, I really missed the feel of coding with VS and VS Code Python really does a great job of bringing it all together, so big ups to all you guys 😃

@nosisyphus
Copy link

How do I get rid of this? I want shift+enter to run selection on a terminal and the only way I can do this now is by pressing ctrl+shift+p and selecting that instruction. currently its trying to connect to a jupyter notebook and it fails everytime. very frustrating...

Executing code failed : Error: Failed to connect to Jupyter notebook.
http://localhost:8888/
TypeError: request to http://localhost:8888/api/contents/?1551289757156 failed, reason: connect ECONNREFUSED 127.0.0.1:8888

@rchiodo
Copy link
Contributor Author

rchiodo commented Feb 27, 2019

@nosisyphus there's a setting that determines what shift+enter does. You can use that to force it to send to the terminal.

image

Although it's bad that your jupyter notebook isn't running. Does it crash?

@IanMatthewHuff
Copy link
Member

@nosisyphus Is this a file with interactive cells defined (#%%) that you are working with?

@nosisyphus
Copy link

@rchiodo no, doesnt crash, just tries to connect everytime I hit shift+Enter, then I get that message. I was able to go back to terminal, though, thanks to you!
@IanMatthewHuff no, regular .py with 1 line, as I was trying to test the new feature.

@rchiodo
Copy link
Contributor Author

rchiodo commented Feb 27, 2019

Sorry I should have been more specific. ECONNREFUSED can happen if the jupyter server crashes. Or if you have a remote server URI specified (another setting we have).

So you'd have to check if jupyter was running still or not.

@rchiodo rchiodo closed this as completed Apr 24, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 22, 2019
@microsoft microsoft unlocked this conversation Nov 14, 2020
@DonJayamanne DonJayamanne transferred this issue from microsoft/vscode-python Nov 14, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants