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

Startup script for temporary interactive console debug sessions #1168

Open
hmmwhatsthisdo opened this issue Jan 18, 2018 · 9 comments
Open
Labels
Area-Debugging Issue-Enhancement A feature request (enhancement).

Comments

@hmmwhatsthisdo
Copy link

hmmwhatsthisdo commented Jan 18, 2018

System Details

  • Operating system name and version: Windows 10 x64 (Multiple builds)
  • VS Code version: 1.19.2
  • PowerShell extension version: 1.5.1
  • Output from $PSVersionTable:
Name                           Value
----                           -----
PSVersion                      5.1.15063.786
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15063.786
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
PS C:\> code -v
1.19.2
490ef761b76b3f3b3832eff7a588aac891e5fe80
x64
PS C:\> $pseditor.EditorServicesVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
1      5      1      0


PS C:\> code --list-extensions --show-versions
[email protected]
PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.15063.786
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15063.786
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

As it stands, debugging a module in VSCode is still a bit clunky. Debug configurations allow for generating a temporary integrated console for every debug session, but using this option requires manually importing the module every debug session.

There is also the option of running a script via the script attribute in a debug configuration entry, which could potentially be used to run environment setup (module import, etc.) - however, the integrated console closes once the script completes. It would be helpful if there was a way to specify a startup script for temporary consoles in a debug configuration, so module imports and whatnot could be done automatically.

@hmmwhatsthisdo
Copy link
Author

After speaking with @seeminglyscience on the PowerShell Slack team, it sounds like most of the work needed for this would be on the PSES side - however, I'm having trouble figuring out specifically what would need to be implemented on the PSES side vs. what would need to be implemented here.

@rkeithhill
Copy link
Contributor

There is already a startup script Microsoft.VSCode_profile.ps1 . It just is a user thing instead of a workspace thing. Given the way the PSIC works now, any sort of "startup" only needs to be run once because the language session and all debug sessions share the same PowerShell instance. You can see this with $pid in the PSIC at various phases of its use. Unless you are using temp integrated consoles, which disappear before you get a chance to check your output. :-(

That said, I do think it would be nice to have a workspace specific startup script or maybe even a workspace profile. The downside to a startup script is that we'd need to make that a setting and then we'd need to pass the path to the startup script from the extension to PSES (not a big downside mind you). If we made it a profile, it would have a specific name and if it existed it would just get run with no need to specify any extension setting. Either way, at this time, the default behavior would be that it runs once, when PSES first starts.

For a temp integrated console, perhaps a workspace profile could access variables to let you know which debug launch config is currently active. This is where I dither a bit. Is it easier to have a single workspace profile that could tell the diff between lang/debug sessions and know which debug config (name?) is active and then put all your logic in there to handle different debug scenarios. Or is it easy to have a property on the debug launch config where you specify a path to various startup scripts.

@SeeminglyScience
Copy link
Collaborator

I believe he's talking mostly about temporary interactive debugging sessions which is where an init script would be the most helpful.

Or is it easy to have a property on the debug launch config where you specify a path to various startup scripts.

That was my thought. I can see that potentially being useful for all debug configuration types, but in particular temp interactive sessions. Assuming that's a reasonably easy property to add, I think that's the best way to go.

About workspace profiles, I really like the idea of them for preparing intellisense/loading editor commands from #190. I think mixing debugging into that, or having a separate profile for it might be confusing.

@rkeithhill
Copy link
Contributor

I think mixing debugging into that, or having a separate profile for it might be confusing.

Well for the vast majority of folks that will not discover the temp int console setting, such a profile would mix with debugging. Maybe that setting should be a setting on the launch configuration instead - at least for configs like launch script, current file and current file w/args. We also really, really need to fix the behavior that the temp console closes immediately after the script finishes.

@hmmwhatsthisdo hmmwhatsthisdo changed the title Startup script for interactive integrated console debug sessions Startup script for temporary interactive integrated console debug sessions Jan 18, 2018
@hmmwhatsthisdo hmmwhatsthisdo changed the title Startup script for temporary interactive integrated console debug sessions Startup script for temporary interactive console debug sessions Jan 18, 2018
@hmmwhatsthisdo
Copy link
Author

hmmwhatsthisdo commented Jan 18, 2018

@rkeithhill, @SeeminglyScience: I totally neglected to mention I was talking about the temporary interactive console - whoops! I'm editing the issue text now.

Or is it easy to have a property on the debug launch config where you specify a path to various startup scripts.

This is what I think would be the easiest from a usability perspective - that, or re-use the current script attribute on debug configurations and add an attribute similar to PoSH's -NoExit switch.

@mud5150
Copy link

mud5150 commented Mar 6, 2019

I would also love to see this happen. Using the createTemporaryIntegratedConsole reduces the side effects from loading the module multiple times. I would love to also have some way to have it load the module into the temp console when I hit debug.

@JustinGrote
Copy link
Collaborator

@SydneyhSmith this should probably be reclassified to an enhancement.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Apr 22, 2020
@SydneyhSmith SydneyhSmith added Issue-Enhancement A feature request (enhancement). and removed Issue-Bug A bug to squash. Needs: Maintainer Attention Maintainer attention needed! labels Apr 23, 2020
@mdgrs-mei
Copy link

Now it seems that the temporary integrated console does not close after the script finishes which means it could be used as a startup script.

I'm using [email protected].

@jul-m
Copy link

jul-m commented Sep 21, 2024

Now it seems that the temporary integrated console does not close after the script finishes which means it could be used as a startup script.

I'm using [email protected].

Indeed, the console does not close, but the debugger stops, so it is not possible to debug when the script property is set. This is not due to the vscode-powershell plugin, but related to PowerShellEditorServices.

I was able to find a workaround by modifying a line of code in PowerShellEditorServices. I opened a discussion in their repository for interested people: PowerShell/PowerShellEditorServices#2180

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

No branches or pull requests

9 participants