Skip to content

VSCode (Powershell) starts with two terminals open: Powershell Integrated and "pwsh" #3925

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

Closed
5 of 6 tasks
github-account1111 opened this issue Apr 19, 2022 · 21 comments
Closed
5 of 6 tasks
Labels
Issue-Discussion Let's talk about it. Resolution-Answered Will close automatically.

Comments

@github-account1111
Copy link

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

Same exact issue as microsoft/vscode#136609 except that one was seemingly ignored and closed.

PowerShell Version

PS> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.0-preview.3
PSEdition                      Core
GitCommitId                    7.3.0-preview.3
OS                             Microsoft Windows 10.0.22000
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

PS> code --version
1.66.2
dfd34e8260c270da74b5c2d86d61aee4b6d56977
x64

Extension Version

PS> code --list-extensions --show-versions | Select-String powershell

[email protected]

Steps to Reproduce

Open a .ps1 file.

Visuals

No response

Logs

No response

@github-account1111 github-account1111 added the Issue-Bug A bug to squash. label Apr 19, 2022
@ghost ghost added the Needs: Triage Maintainer attention needed! label Apr 19, 2022
@andyleejordan
Copy link
Member

Hi there,

The PowerShell extension opens the "PSIC" (PowerShell Integrated Console) on activation as it's hosting the LSP server.

VS Code opens a regular pwsh terminal.

You can configure both of these options, the extension's with:

"powershell.integratedConsole.showOnStartup": false

(Note that if you do this, you'll have to manually run "PowerShell: Show Integrated Console" to get it open later, see #3918.)

And VS Code's terminal documentation is here.

@andyleejordan andyleejordan added Issue-Discussion Let's talk about it. Resolution-Answered Will close automatically. and removed Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed! labels Apr 19, 2022
@github-account1111
Copy link
Author

Does hosting the LSP server require opening an extra Powershell session?

Also worth noting that this was not happening before I installed Powershell 7.

@andyleejordan
Copy link
Member

Does hosting the LSP server require opening an extra Powershell session?

It requires the PSIC session, yes. But as shown, you can hide that if you wish.

Also worth noting that this was not happening before I installed Powershell 7.

I don't think that VS Code will open a pwsh terminal on startup unless you install pwsh (which is PowerShell 7).

@github-account1111
Copy link
Author

github-account1111 commented Apr 20, 2022

"Extra" was the keyword in my question.
Can't it switch to 7 for PSIC, given that it's a superset of 5.1, instead of spawning an extra session?

@andyleejordan
Copy link
Member

No, as I stated, the extension only starts PSIC. It is not an "extra" is is the one and only that the extension spawns and hides control over. You may hide it at startup if you wish.

You can set VS Code to do whatever you wish with your other terminals. You seem to not want it to start a pwsh terminal on startup, go configure that. I linked you to the documentation earlier. I can't answer why VS Code doesn't start a powershell by default; I'm not a VS Code maintainer.

Thanks for using the extension!

@github-account1111
Copy link
Author

@andschwa You seem to have misunderstood my question.
I'm asking why the extension doesn't opt to use 7 for PSIC instead of 5.1.
It can obviously see that 7 is present because it opens it along with 5.1.

You seem to not want it to start a pwsh terminal on startup, go configure that.

No.
I want it to start pwsh only (i.e. 7).
I don't want it to start 5.1 (whether it be hidden or not).

@andyleejordan
Copy link
Member

@andschwa You seem to have misunderstood my question.
I'm asking why the extension doesn't opt to use 7 for PSIC instead of 5.1.
It can obviously see that 7 is present because it opens it along with 5.1.

The extension does use PowerShell 7 if available. You can actually choose which installed copy of PowerShell you want to use!

@github-account1111
Copy link
Author

github-account1111 commented Apr 20, 2022

The extension does use PowerShell 7 if available

But that's obviously not the case.
Here 7 is available, yet it still uses 5.1.
That is literally the point of this entire issue.
It should do it, but it doesn't do it.

@andyleejordan
Copy link
Member

You didn't follow the bug report and provide any logs or screenshots. It does use PowerShell 7, as many users can attest to. Please give us more information if you need further assistance!

@github-account1111
Copy link
Author

I think this is a case of selective reading.
I never said it doesn't use 7, period.
This is what I said:

I'm asking why the extension doesn't opt to use 7 for PSIC instead of 5.1.

I didn't think a screenshot is needed given I'm experiencing the exact same issue as the one I linked, and that one does contain a screenshot, but here you go:

image

logs.zip

@andyleejordan
Copy link
Member

Ok run $PSVersionTable in PSIC. If it's not the version want, follow the instructions I linked you to earlier to change it.

@github-account1111
Copy link
Author

github-account1111 commented Apr 21, 2022

It's the one I want.
Both pwsh and PowerShell Integrated Console are version 7.

image

Why does it do that?

@andyleejordan
Copy link
Member

I'm sorry, I don't understand your question or what you're having trouble with.

@github-account1111
Copy link
Author

Why does it open two Powershell 7 terminals instead of opening one?
It makes no sense.
Am I supposed to use one over the other for certain tasks?

@joe-miller-hgs
Copy link

i am having the same problem as github-account1111.
when i open vscode powershell extension, i get two terminals:
image
and
image

i don't want two terminals.
this problem started when i installed pwsh.
the dual terminals only appear when i select pwsh in the session menu.
if i caused the problem somehow when i installed pwsh, i have no idea how and no idea how to fix it.

here's my session menu:
image

i prefer to have only the PSIC terminal when i open vscode with pwsh selected.
i don't need or want a duplicate terminal.
at minimum, it causes a big chunk of my terminal window to be consumed by the two-terminal list on the right, as shown in the first two images.
it also causes problems if i accidently close the wrong terminal when i try to restore my full terminal window.

what other info can i provide to help you diagnose this problem?
thanks for your time.

@ghost
Copy link

ghost commented Mar 21, 2023

Thank you for your comment, but please note that this issue has been closed for over a week. For better visibility, consider opening a new issue with a link to this instead.

@Lingxi-Li
Copy link

Since PSIC is used by LSP server, it should be treated as an implementation detail and not be exposed to user as this causes confusion. E.g., when I saw the two sessions, I mistakenly thought that one is using PowerShell 7 and the other is using PowerShell 5.x shipped with Windows and I killed the latter. That said, the PSIC should be hidden by default.

@andyleejordan
Copy link
Member

The vast majority of users request that the integrated terminal is exposed, as it's useful for debugging etc. As pointed out above, you can set it to be hidden on startup and behave exactly as you want. No default will satisfy everyone.

@toni1elias
Copy link

I have the same issue.
If I open a .PS1 file using File > Open File... menu option, only one terminal is shown.
If I opened the file by right-clicking it and choosing Open in VS Code, two terminals will show up.

@begna112
Copy link

I think the issue is not the PSIC appearing, but the useless secondary pwsh terminal that also opens. Having an extra terminal open in every vscode window that's working in PS projects isn't great for resource management.

image
image

@andyleejordan
Copy link
Member

Agreed, but that's an issue with VS Code that you can't disable that pwsh from opening; as an extension author I cannot prevent that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Discussion Let's talk about it. Resolution-Answered Will close automatically.
Projects
None yet
Development

No branches or pull requests

6 participants