Search code examples
pythonvisual-studio-codesshremote-server

Run Current File in Interactive Window opens a preview instead


On Visual Studio Code, from time to time, this very weird behavior happens: When I click on Run Current File in Interactive Window, instead of opening an Interactive Window and running my code, it opens a Preview of my code. When it happens, the only solution I've found to solve the problem is to close and reopen VS Code.

When I click for the first time on Run Current File in Interactive Window, it works properly: enter image description here

If I close the Interactive Window and click again on Run Current File in Interactive Window, then it opens a Preview of the code instead of the Interactive Window: enter image description here

I'm using the April 2023 (version 1.78) release Visual Studio Code and I think the issue only appears when I'm using VS Code on a remote SSH server.


Solution

  • EDIT:

    The problem was with the Auto-Open Markdown Preview extension, after disabling this extension the problem was solved.

    enter image description here


    First make sure you have the full Python extension installed, if you are using VS Code on a remote SSH server, install the extension on the ssh host as well.

    In addition, you can Ctrl+Shift+P --> Python: Restart Language Server try to restart the language server.

    At the same time, some of your personal settings may cause problems. You can check whether the problem can be solved by disabling extensions or deleting personal settings.