-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
Debugging without an open folder #285
Comments
I see that your scenario would not require the workspace, however our vscode frontend has to support multiple languages to debug and for most having a workspace is required. Also debugging requires a launch.json file, and when there is no workspace there needs to be a shared launch.json which is a bit cumbersome. Due to the above this is by design. |
So keep it as an open issue in case someone wants to code up a solution? Or is it something that we don't want to have at all because it would make the product worse? |
Let's keep it open for now then |
Yes this would be a useful feature. Debuging just a single file. Please add this. |
I'd like to explain a possible use case for this. I use vscode to write PowerShell scripts, these are usually single-files. I'd like to be able to open a Powershell file, set some break points and debug the script like I can with the PowerShell ISE |
I'm starting to see a real need for this in the PowerShell extension but I'll bet that it'd also be helpful for other languages with a more dynamic/interactive development workflow (Python, F#, etc). Here's a thought:
It may be necessary to also have a different type of default, single-file configuration or maybe some way to generate one. I realize there's some work required to enable this, but does this set of steps sound reasonable? |
Yeah, this is one of the core expectations of PowerShell users since it's a primary development workflow in the PowerShell ISE editor. I would love to work with you guys to find out a good way to enable this without disrupting the existing folder-based debugger configuration. |
I would also like this feature. Opening a single file with vs code feels kind of useless. Is it bad if vs code automatically opened the parent folder when someone opens a file with vs code. |
Ok let's do this, moving to January for exploration. 1. Have a shared "launch.json" in a user folder which is used for all no-folder workspaces
2. No "launch.json" - implicitly always send the path to the currently opened file to the adapterA user who gets used to this scenario might be shocked that once he opens a workspace he needs to setup a complex launch.json. This option obviously has the pro of being simple to setup but opens the following questions: How to choose the correct adapter for a particular file, e.g a hello.ps1 script?Currently adapter are not contributing in any way the extensions of the files they are interested in except via the Do we always launch or give a user to choose between launch / attach?We could do this choice via quick pick but it is painful that the user always has to choose launch every time he wants to simply run his script. Recently we were talking to a team that have a use case of always attaching, so we should also support this imho. Two options of quick pick not annoying the user:
Does the adapter require some arguments in the "attach" case?Can the adapter just always pick the default port or do we need to do the pick process action? UI state in no folder workspaceAll ui state is preserved until vscode is closed. Which means on vscode restart all breakpoints will be lost. IMHO this is fine for the no folder debug scenario as this is our general no folder experience. If you want persistent state open a folder. |
I don't like option 1 because managing a shared launch.json somewhere on disk sounds complex and it has the problems already identified by @isidorn. For option 2 I propose a solution that aligns nicely with the theme to open up debugger functionality for extensibility. The basic idea is to optionally route the "debug" or "run" requests to a debugger extension which can modify a launch config in any way needed. In the "Debugging without an open folder" context the extension would have to create a launch config on the fly because none exists in the no-folder mode. Details:
|
This looks great! I'll give it a try today. Judging from the code changes, it looks like this will also call my |
Ahhh, finally just read Andre's design proposal above. I suppose this means the user will still be prompted to create a launch.json config on first launch in an open workspace. That seems ideal because it will allow the user to save debugger config parameters in their project's launch.json while still allowing the extension to augment their config before launching the debugger. This is really nice! |
Yes.
No. |
That might be even better! I'll hold any further questions until I try it tomorrow :) |
@daviwil I've updated the code in https://github.com/Microsoft/vscode-node-debug/blob/master/src/node/extension.ts#L256 to cover all cases. |
This is helpful, thanks! And thanks so much for getting this feature implemented, it's going to have a huge impact for the PowerShell extension. |
Just tried this out, it's fantastic! It works exactly like I hoped it would both with and without a folder loaded. One problem though: after I execute the This even happens when I take my |
I should mention that to debug the issue I've set breakpoints in |
Just thought to check this with the latest official release of the PowerShell extension, version 0.8.0 which came out in mid-December. When starting the debug adapter it hangs on startup in the same way that I described above. Something definitely must have changed in how the debug adapter client communicates with debug adapters, but I'm not quite sure how. If you want to give this a try, install the PowerShell extension and open the following folder (adjust the path appropriately for OS X if needed):
Open the |
@isidorn David's problem sounds like a regression to me. Can you look into this? |
Just verified that VScode is sending exactly the same requests as before. I am currently git bisecting to see what commit caused the issue |
Here's the commit that breaks it - praise git bisect 🙏 Here's the commit that fixes the issue fb838d2 |
@isidorn but your commit does not explain what went wrong with the Map code. I'm using the identical Map code in node-debug and have no issues... |
Sorry about that, I'll use Insiders from now on. I had been using it in the past but somehow switched back over to stable. Just pulled down the latest code after your change, that fixed it! Everything works perfectly now. Thanks a lot Isidor! |
After closer inspection with @weinand we figured out that the exact issue is that powershell is sending back |
Hah! Wow, wouldn't have expected that. Yep, I'll make the change. |
I can confirm that changing |
Awesome - we'll go back to using a map |
Why is folder required to have debugging enabled?
Case in point - trying out single file ps scripts. Am I missing something?
The text was updated successfully, but these errors were encountered: