-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Send extra newline for 'Run Selection/Line in Python Terminal' to immediately execute #169
Comments
From @TiemenSch on August 28, 2017 17:29 What happens if you add a new line at the end of your file? Update: Running the complete file works just fine. |
From @ruben-aghayan on August 29, 2017 17:21 Hi Tiemen, When I add a new line at the end of the file, it is also pasted into IPython, but the code is not run. Running line by line is an important part of workflow in cases like Data Science. It also makes the most of some of the interactive features in IPython. |
Possibly related to https://github.com/DonJayamanne/pythonVSCode/issues/1180 |
@ruben-aghayan are you able to test this on the latest version of VS Code and let us know whether it works. |
As far as I can tell, the issue is still there. Has it stopped on your machine? / Is it just me? |
This bug also occurs for me, exactly as initially described. |
@ruben-aghayan @amccaugh
Please test and confirm this is the behavior outside VS Code. |
The issue persists if a blank line is included then the 'run selection' command is given. If, in order to run the line, the user must change the focus to IPython and hit enter ( and this can't or shouldnt be done in the Run Line/Selection command) then I think we can close it. |
@DonJayamanne In my terminal (windows), using IPython 6.1.0 (Python 3.6), I do not need to hit the enter key twice. The behavior I see is:
|
I've also tested this on a Debian box with IPython 0.13.1 + Python 2.7, and it's the same behavior (a single keypress of enter evaluates the line). From what I can tell, getting a newline in the IPython prompt is actually somewhat difficult |
@ruben-aghayan @amccaugh |
I have installed the latest development version of the extension. As before, running the first line of the selection executes nicely in ipython - this has never been an issue for me. The rest of the selection however, does not. This behaviour has been described in #460 already and it is still marked as needs-verification. |
Ignore the other issue; it's closed. Can someone upload a GIF showing what's happening for them including what OS, Python version, and IPython version they are using? We simply can't reproduce on our machines (I tested this issue the other day and couldn't reproduce either). |
@boazdori no current plans to do so. |
@boazdori If you're interested in seeing a preview of what this experience could look like, take a look at this extension: https://marketplace.visualstudio.com/items?itemName=neuron.neuron-IPE I had some students build this proof of concept for us - would love to hear your feedback! |
@jflam This looks very promising. Quite similar and potentially more powerful than hydrogen package for atom IDE |
Tried it thanks
What I am really missing in vs code python is
1. Console - Ipython
2. Variable explorer
Functionality that matlab has
Thanks
Boaz
From: John Lam <[email protected]>
Sent: Thursday, August 16, 2018 6:51 PM
To: Microsoft/vscode-python <[email protected]>
Cc: boazdori <[email protected]>; Mention <[email protected]>
Subject: Re: [Microsoft/vscode-python] Send extra newline for 'Run Selection/Line in Python Terminal' to immediately execute (#169)
@boazdori <https://github.com/boazdori> If you're interested in seeing a preview of what this experience could look like, take a look at this extension: https://marketplace.visualstudio.com/items?itemName=neuron.neuron-IPE
I had some students build this proof of concept for us - would love to hear your feedback!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#169 (comment)> , or mute the thread <https://github.com/notifications/unsubscribe-auth/AZGAzCAju28RNfQ-nNjt6U1SyJW466zHks5uRZThgaJpZM4Qdo0R> . <https://github.com/notifications/beacon/AZGAzOPVHFWWTHbhd-BEcHUUK8NgYqbZks5uRZThgaJpZM4Qdo0R.gif>
|
@boazdori Agree! I think this two features are critical for vs code replacing Spyder, if this is fix I won`t hesitate to uninstall Spyder. |
Thanks! @boazdori we're definitely going to be moving forward with building out this feature set (and others) soon. Stay tuned. |
I've just installed vscode. Honestly, it's hard to believe this functionality isn't present. We are talking about running code in the most popular shell for data analysis. uninstalling asap vscode. A piece of advice: try to mimic Rstudio's functionality, otherwise it's useless for data science. A text editor with iPython is just better. |
@martinbel did you try the Neuron extension linked above? We are working on turning the Neuron experience into the Microsoft experience. |
Thanks for the suggestion but I've just finished setting up vim + tmux + vim-slime that has all I need really. I'll give it a try later on, thanks! |
@DonJayamanne Has any progress been made on this front? So far, the best I could do to approximate the desired behavior, i.e. multiple selected lines properly sent and executed in the IPython terminal, was to manually send the extra line break a few milliseconds after the original code was sent. This works well for few selected lines, but of course becomes a problem when the number of selected-and-sent lines increase. |
The original issue entered was not about data science, but only the existing python terminal window. This bug will now only track this issue. The other Python Interactive window issues scattered throughout this issue are likely covered by #727. |
I've been looking at a few ways to address this issue. Here are some approaches:
{
"key":"ctrl+`",
"command":"workbench.action.focusActiveEditorGroup",
"when":"terminalFocus"
},
{
"key":"ctrl+`",
"command":"workbench.action.terminal.focus",
"when":"!terminalFocus"
},
{
"key":"alt+enter",
"command":"python.execSelectionInTerminal",
"when":"editorFocus && !findInputFocussed && !replaceInputFocussed && editorLangId == 'python'"
},
{
"key":"alt+shift+enter",
"command":"workbench.action.terminal.sendSequence",
"args":{ "text": "\u000d" }
}
public async sendText(text: string): Promise<void> {
await this.ensureTerminal();
this.terminal!.show(true);
this.terminal!.sendText(`${text}`);
// send carriage return to make code execute
await new Promise(resolve => setTimeout(resolve, 100));
this.terminal.sendText('\u000D', false);
await new Promise(resolve => setTimeout(resolve, 100));
}
{
"key":"alt+shift+enter",
"command":"python.datascience.execSelectionInteractive",
"when":"editorFocus && !findInputFocussed && !replaceInputFocussed && editorLangId == 'python'"
} and I also sometimes open a REPL in the terminal interface connected to the same kernel with |
We're not fixing the issue as stated because of limitations with the terminal. Closing in favor of #727 |
@saponas this works. can combine opt1 with multi-command ext, too. |
From @ruben-aghayan on August 25, 2017 23:2
Environment data
VS Code version: 1.15.1
Python Extension version: 0.7.0
Python Version: 3.6.2
IPython Version: 6.1.0
OS and version: Windows 10 Enterprise 1703
Actual behavior
Pastes selected line(s) into IPython but does not run them. There is a new line at the end of the pasted text.
Observed ouptut from highlighting line or leaving cursor on line and issuing Run Selection/Line in Python Terminal command when IPython is default interpreter
Expected behavior
To run selected line(s)
Steps to reproduce:
Copied from original issue: DonJayamanne/pythonVSCode#1180
The text was updated successfully, but these errors were encountered: