Skip to content

PowerShell Integrated Console starts when opening first PowerShell script #1169

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
atkinsroy opened this issue Jan 18, 2018 · 17 comments
Closed

Comments

@atkinsroy
Copy link

atkinsroy commented Jan 18, 2018

System Details

  • Operating system name and version: Windows 10 Version 1607, Build 14393.2007
  • VS Code version: 1.19.2
  • PowerShell extension version: 1.5.1
  • Output from $PSVersionTable:

[email protected]
[email protected]
[email protected]
[email protected]
[email protected]

PSVersion 5.1.14393.1944
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.1944
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

I also have PowerShell Core, but this is not related, as I saw the same behaviour before installing this:

PSVersion 6.0.0
PSEdition Core
GitCommitId v6.0.0
OS Microsoft Windows 10.0.14393
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Note, I also had this problem before installing the shell launcher extension, as detailed above.

Issue Description

PowerShell Integrated Console automatically starts when opening first PowerShell script in session.

On my system, the PowerShell extension will open a console called "PowerShell Integrated Console" and switch to it when I open my first PowerShell script in the session. It does this even if I have another PowerShell console running. If I open VS Code and in the previous session I had a PowerShell script open, then the extension does the same thing (the console might be displayed or might be hidden).

I really don't like this behaviour - this console (labelled "PowerShell Integrated Console") behaves differently to other PowerShell consoles (e.g. it doesn't appear to run my profile, you cannot exit it and syntax colouring doesn't work).

I've improved things by using the following user setting; at least now when the console is created, I don't get switched, so its easier to ignore, but it still appears in my console list.
"powershell.integratedConsole.showOnStartup": false,

I'd really like a way to stop this console from starting. If I press ctrl ` I get a correctly behaving PowerShell console (labelled "powershell") and the same thing if the console window opens from last session. Can I suggest:
"powershell.integratedConsole.showOnFileOpen"

Attached Logs

vscode.zip

@dsolodow
Copy link
Contributor

dsolodow commented Jan 19, 2018

this console (labelled "PowerShell Integrated Console") behaves differently to other PowerShell consoles (e.g. it doesn't appear to run my profile, you cannot exit it and syntax colouring doesn't work).

The PowerShell Integrated Console does run profiles, but as it's a different Host, it doesn't use the same host specific profile:

  • "Standard" PowerShell: Microsoft.PowerShell_profile.ps1
  • "PowerShell Integrated Console": Microsoft.VSCode_profile.ps1
    What I do is use the $currentUserAllHosts profile (profile.ps1) and have some IF statements for host specific settings.

The syntax coloring in the console is from the PSReadLine module and there is an open request on that already ( #535)

@wsmelton
Copy link

wsmelton commented Feb 4, 2018

@atkinsroy one note in reference this comment:

I really don't like this behaviour - this console (labelled "PowerShell Integrated Console") behaves differently to other PowerShell consoles (e.g. it doesn't appear to run my profile, you cannot exit it and syntax colouring doesn't work).

The extensions integrated console is required to be running in order for intellisense and other features within the editor (where you develop your scripts) to function. They go hand in hand. If you are working on a script where you are using a module say from PS Gallery, the first time you reference a command in that module the Editor service will load the module into that integrated terminal used by the extension. You then have intellisense on commands for that module. It works both ways.

You can see the dependency this has by deleting that integrated terminal created by the extension. Once you do that you will lose all functionality of the extension.

In reference to why it behaves differently is because it is not the same host as if you are using powershell.exe or pwsh.exe. In VS Code PowerShell extension, the PowerShellEditorService is the engine behind all the features and that integrated terminal that are added to the environment within Code.

You can disable the integrated terminal from showing at all by setting "powershell.startAutomatically" to false. However, the downside to this will be you won't have intellisense in your PS1 files and ability to execute or debug code is gone.

@atkinsroy
Copy link
Author

Hi Shawn,

Thanks for the follow up. I've done some reading and understand the need for the integrated console now. I just find that it crashes quite a bit, so I've learned to not rely on it for integrative sessions. I do miss out on RunSelections, but having colourisation is more important for me.

@TylerLeonhardt
Copy link
Member

@atkinsroy hey there, thanks for your concern! I will say that crashing is not a feature 🙂

If you ever experience a crash, we want to know about it so we can fix it.

We try to make it as painless as possible to file issues so that we can get the info we need to fix the issues you're experiencing. Take a look out how to send us logs here:
https://github.com/powershell/vscode-powershell#reporting-problems

Don't hold back 💪 we can take it.

@splatteredbits
Copy link

Maybe separate these two things? Every time I open any PowerShell file, I have to close that dang console that pops up. It's death by a thousand paper-cuts, so I continue to use the ISE. Intellisense and editor services should a non-interactiver console it uses. Then, if I want to run an interactive console for debugging, I can open one.

@wsmelton
Copy link

wsmelton commented Jul 31, 2018

@splatteredbits you can resolve the terminal opening by setting the below to false in your user settings, by default it is set to true:

 // Shows the integrated console when the PowerShell extension is initialized.
  "powershell.integratedConsole.showOnStartup": true

The session starting has to happen as that is part of the editor services. You will not have all the features of the PowerShell extension with out them/it.

@splatteredbits
Copy link

@wsmelton That's not what I want. I want Intellisense and all that without a console opening.

@rjmholt
Copy link
Contributor

rjmholt commented Aug 1, 2018

@splatteredbits Setting:

{
    "powershell.integratedConsole.showOnStartup": false
}

Should give you intellisense without a console opening. If that's not happening, there's probably a bug.

The console itself is just a window into the PowerShell session used to host EditorServices though. So console or not, there's a PowerShell process running in the background to provide intellisense.

@splatteredbits
Copy link

@rjmholt Yay. That works. I got confused about earlier statements that I would lose intellisense with that setting.

@Fontenot-Tech
Copy link

Another ISE feature that has 'forced' me to use the Powershell Integrated Console is to highlight a portion of code, right-click and select 'Run Selection' (or F8). This code is only executed in the Integrated Console...and I didn't realize how much I relied on that button when developing scripts within the ISE. I too, was like many new comers to Code, or those of us that enjoy fine-tuned control of EVERYTHING (we are developers, engineers, and admins, after all), found the 'extra' Integrated console baffling at best and annoying at worse...especially since a 'normal' Powershell console loads as the terminal anyway.

Lately, I've found myself using it almost exclusively though. Partly b/c of the F8 integration working (copying and pasting large sections of code into the terminal doesn't always work, as it tries to execute each line of code as it sees it...which is a pain for loops and other constructs) and partly since discovering that you can load a profile and that there has been some improvements with the colorization.

Similar to ISE vs Powershell Console, it is another, separate executing environment, and as such there are slight variations in behavior (none of which have bitten me in the but...i think they are trying to mirror the console environment as closely as possible).

But the neat-freak side of me says, give me one or the other. I understand that the Integrated Console is necessary to run the extension properly. Then just make the Integrated Console THE powershell console, make it pretty, and add the profile thing to Help or tooltips to make it easy for us noobs to figure that out.

@flarpblart
Copy link

Is there any way to always open the powershell integrated console (the one included with the extension) over what you get when you just have powershell set as your terminal?

@raaaaaymond
Copy link

Setting powershell.integratedConsole.showOnStartup to false doesn't seem to work for me. The integrated Powershell terminal still opens. As many others in this thread, I don't want to open an integrated Powershell terminal every time I open the .ps1 file, I just want intellisense. Any suggestions?

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Mar 9, 2020
@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented Mar 9, 2020

@raaaaaymond

It's working for me. Double check.

You need to uncheck this in settings:
image

and then restart vscode.

@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Mar 9, 2020
@raaaaaymond
Copy link

raaaaaymond commented Mar 9, 2020

@TylerLeonhardt Yep that's the option that I unchecked. Restarted and all, but the integrated console still shows up whenever I open a .ps1 file. Could it be that my VSCode is buggy?

My system info is below:

Version: 1.42.1 (user setup)
Commit: c47d83b293181d9be64f27ff093689e8e7aed054
Date: 2020-02-11T14:45:59.656Z
Electron: 6.1.6
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Windows_NT x64 10.0.18362

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Mar 9, 2020
@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Mar 24, 2020
@DavidPeper
Copy link

So what worked for me was to first uncheck "Show on Startup" and then open a cmd prompt and uncheck "Use legacy console.." in the properties. Restarted VSCode and boom, no more PowerShell window and my intellisense is still working.

"Victory is mine!" - Stewie

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Mar 27, 2020
@TylerLeonhardt
Copy link
Member

@raaaaaymond sorry since this issue is closed it slips under my radar... I would encourage you to open a new one with what you are seeing so we can be more responsive...

Can you also try @DavidPeper's suggestion? Also, I'm curious what other VS Code settings you have set if you can also share those.

@DavidPeper odd that that unblocked you.. I will look into that. You should be able to have both of those settings enabled...

@raaaaaymond
Copy link

Thank you @TylerLeonhardt. I haven't tried @DavidPeper's suggestion because I think a recent update (14.3) magically fixed the problem. Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests