Skip to content
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

Setting to disable auto-loading of Integrated Terminal #580

Closed
The-New-Guy opened this issue Mar 17, 2017 · 16 comments
Closed

Setting to disable auto-loading of Integrated Terminal #580

The-New-Guy opened this issue Mar 17, 2017 · 16 comments
Labels
Issue-Enhancement A feature request (enhancement).

Comments

@The-New-Guy
Copy link

This new Integrated Terminal is a great feature. I foresee myself using it a lot in the future. That said, I'm wondering if it would be possible to put in a setting that disables the automatic loading of this terminal when opening PowerShell files. Of course you would also need to a way to load it on demand later.

The VSCode startup process has been getting faster and faster in months past and as such I have started using it to quickly view files instead of Notepad++. I will simply right-click and "Open in VSCode" to quickly take a peak at some script file. However, with this new integrated terminal this now complicates things.

I realize that for most people the loading of the user's PowerShell profile probably doesn't take but a couple seconds to load. However, as a system admin for Lync, Exchange, AD and several others, my profile connects to each of those services and imports a session. This process takes considerable time which is fine on most occasions, however when taking a quick look at a file it can be hindrance.

This is further exasperated by the fact that when the PowerShell extension opens the terminal panel, the VSCode integrated terminal which is also PowerShell will also start loading my profile. So each time I go to quickly view a file I have two separate powershell terminals starting up, each taking considerable time to load all of the imported sessions in my profile.

I could just remove the import of the sessions from the vscode specific powershell profile but if I were to do that I would likely never even use it since 99% of all my development is against these remote services and therefore I need these sessions during my development. I could also just ignore this, hit Ctrl + ` to hide the terminal and close out whenever I'm ready. However, while that most likely won't cause an issue to close out while these sessions are in the middle of an import, it can be problematic if you are doing this repeatedly for several files in a row.

This was also an issue for me in the ISE days. Back when I used to use ISE for everything, I had actually written a PowerShell command, Open-ClipboardFile (with alias ofc), that allowed me to copy a file in Windows Explorer and then open that file in my currently open ISE editor (which ran as a different user than my login user). That way I wasn't loading a new instance of ISE (and thus all of my remote sessions) every time I wanted to quickly look at a file.

@daviwil
Copy link
Contributor

daviwil commented Mar 17, 2017

Absolutely, I can add this. Thanks for the detailed explanation of your situation, also. I was planning on adding a setting for this but I hadn't considered the case where you didn't even want PowerShell to be started for performance reasons (even if the terminal wasn't shown automatically).

I wonder if it makes sense to have 2 options:

  • powershell.startAutomatically: When set to true (default), causes the language service to start automatically the first time a PowerShell file is opened. You could then use the "Restart PowerShell Session" command to kick off the language service on demand.
  • powershell.showIntegratedConsoleOnStartup: When set to true (default), causes the integrated console window to be shown automatically when the language service starts. If false, the language service starts but the console window isn't shown until the user runs script code (or runs the Show Integrated Console command)

What do you think?

@ChrisLynchHPE
Copy link

I agree with @The-New-Guy and the changed behavior of opening the integrated terminal upon VSCode startup. I would be in favor of the powershell.showIntegratedConsoleOnStartup param, and I would personally change it to false.

What impact would there be if you were to set powershell.startAutomatically to false? Would the user lose out on symbol navigation with `Ctrl+P+@'? Or other?

@daviwil
Copy link
Contributor

daviwil commented Mar 17, 2017

Yep, IntelliSense, symbol navigation, code formatting, pretty much anything that's not syntax highlighting.

@The-New-Guy
Copy link
Author

@daviwil I think the two options you mentioned would work wonderfully in my scenario. Thanks.

@General-Gouda
Copy link

Just wanted to throw in my 2 cents and say that powershell.showIntegratedConsoleOnStartup would be very useful. Especially for those with limited screen resolutions. Thanks!

@daviwil
Copy link
Contributor

daviwil commented Mar 20, 2017

I'll ship an update in the next couple of days with these settings.

@latkin
Copy link

latkin commented Mar 21, 2017

Came to the repo searching for some issue related to new auto-start terminal. VS Code already has a built-in terminal, which I have configured to launch powershell. I don't want another random powershell terminal, which doesn't load my $profile, taking up space on my screen and in my brain every time I open a .ps1 file.

Do I understand correctly that with the latest fix, if I disable the auto-start terminal I lose most of the features of the plugin? i.e. "IntelliSense, symbol navigation, code formatting, pretty much anything that's not syntax highlighting" That is extremely unfortunate - this extension was functioning quite well in the past without opening extra terminals...

If the behavior could be changed (or made configurable) such that the auto-start terminal launches "silently" (doesn't cause anything to appear at the bottom, doesn't take focus, not visible at all) then I would be content enough, because I'd never have to see it.

@daviwil
Copy link
Contributor

daviwil commented Mar 21, 2017

The change I made adds two new settings:

         "powershell.startAutomatically": {
            "type": "boolean",
            "default": true,
            "description": "If true, causes PowerShell extension features to start automatically when a PowerShell file is opened.  If false, the user must initiate startup using the 'PowerShell: Restart Current Session' command.  IntelliSense, code navigation, integrated console, code formatting, and other features will not be enabled until the extension has been started."
          },
         "powershell.integratedConsole.showOnStartup": {
            "type": "boolean",
            "default": true,
            "description": "If true, causes the integrated console to be shown automatically when the PowerShell extension is initialized."
          }

Are the descriptions there sufficient to indicate that you can enable language features without having the integrated console show by default? If not, do you have any recommendation on how I can make it clearer? Your desired behavior is supported with these settings, I just want to make sure users will understand that when they read the setting names and descriptions.

Regarding the new console, it does load your profile, just not the same one as powershell.exe: Microsoft.VSCode_profile.ps1. It also loads your $profile.CurrentUserAllHosts and $profile.AllUsersAllHosts profiles. If you want similar things to be loaded in both powershell.exe and the PowerShell extension's integrated console, add it to $profile.CurrentUserAllHosts and check for a $host.Name of "ConsoleHost" or "Visual Studio Code Host". Alternatively you could just dot-source your Microsoft.PowerShell_profile.ps1 script inside of Microsoft.VSCode_profile.ps1.

@dotps1
Copy link

dotps1 commented Mar 21, 2017

ah, so code will have its own profile the same as the ise does. very good idea @daviwil !!

@latkin
Copy link

latkin commented Mar 21, 2017

Ah, I did not realize showOnStartup was exposed, this does look like what I want. From comments here I assumed it was all-or-nothing. I think that description is good.

@daviwil
Copy link
Contributor

daviwil commented Mar 21, 2017

Cool! Glad to hear it. I'll have a new update out tomorrow with these settings added.

@daviwil
Copy link
Contributor

daviwil commented Mar 23, 2017

Just release 0.11.0, check it out and let me know what you think!

@The-New-Guy
Copy link
Author

@daviwil This is exactly what I was looking for. Thank you very much!

@daviwil
Copy link
Contributor

daviwil commented Mar 23, 2017

Awesome, thanks a lot for trying it out!

@sourabh504
Copy link

Hey @daviwil what to do make your changes work for me?

@TylerLeonhardt
Copy link
Member

@sourabhranka to not start the PowerShell extension automatically, simply go to your settings in vscode and search for powershell.startAutomatically. You can set that to false by clicking on the little pencil icon.

Keep in mind, you'll loose out on all of the features: IntelliSense, code navigation, integrated console, code formatting, etc until you run: PowerShell: Restart Current Session in the Command Pallet (ctrl+shift+p)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

No branches or pull requests

8 participants