microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.31k stars 1.18k forks source link

Python REPL isn't restarted after exiting and rerunning shift+enter #22547

Open joyceerhl opened 10 months ago

joyceerhl commented 10 months ago

Testing #22533

  1. Shift+enter to start a REPL and send some Python code to the REPL
  2. In the REPL, run exit()
  3. Now there is still a Python terminal image
  4. Shift+enter again
  5. :bug: the existing Python terminal is reused but the REPL isn't restarted, so my selection is just dumped straight to the command prompt

Can we use shell integration here to restart the Python REPL or even switch the terminal type back to powershell after the user types exit()? cc @tyriar

Lauler commented 4 weeks ago

This is still an issue, and has become even more of an issue lately.

  1. After a restart of VSCode, the IDE tries to be smart and remember (reopen) the shells that were open the previous time a user closed VSCode.
  2. The shell that was previously active as a Python REPL now becomes a regular bash/zsh/powershell shell after restarting VSCode.
  3. When the user highlights code and presses Shift+Enter, the Python code is "smartly" sent to the shell that Python was previously active (it says Python in the VSCode terminal, but in actuality the regular shell is active).
  4. Lots of import library_name are sent to the shell, causing the user's computer to freeze for several seconds as the shell deals with erroneous imports.
  5. Files are created with the names of the python libraries that were attempted to be imported in the shell.