Understanding how python.execSelectionInTerminal
works
#22732
Unanswered
matiasandina
asked this question in
Q&A
Replies: 1 comment 2 replies
-
This is all by design. If you would like to request new functionality, please open a feature request. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have been having some hiccups with
python.execSelectionInTerminal
. I mapped it toCTRL + ENTER
as a shortcut.I am unsure my expected behavior is the actual way this works.
Open a new file, type
Results:
Opens a new terminal window, initiates REPL, and runs the code.
I take this is the intended behavior. But I find it to be in conflict with different situations
Previously initiated python
If initiate python on the terminal. Hitting CTRL + ENTER will create a new terminal window just as above.
Working on a different directory
If I first cd into a folder on the terminal and then hit CTRL + ENTER, a new terminal window will be created, just as above in the same dir as the first time around. This is an immediate problem since the scripts will not find the proper objects in path.
Hacks
To be able to have CTRL + ENTER go to the proper terminal and the proper working directory, I have to first initiate the repl, then exit, then change dirs, then run again. I don't believe this is by design, but I might be wrong.
I am not making use of changing the directory inside python since this is to illustrate that
python.execSelectionInTerminal
somehow cares about having an initiated terminal window called Python with the cmd icon and only then anypython.execSelectionInTerminal
will go to the desired terminal. It seems that you can only have one active terminal and all code will go there (you cannot have code going into different python instances from different files).The most pressing issue is when running code that lives under several folders
/root/module1/module1.py
,/root/module2/module2.py
but originally working from/root/
as it's more convenient to open that folder in VSCode to handle all code.Hitting CTRL + enter opens a REPL in
/root
, which obviously immediately crashes code that depends on the folder structure. What I found is very similar to related issues with opening new terminals #21393.Beta Was this translation helpful? Give feedback.
All reactions