-
Notifications
You must be signed in to change notification settings - Fork 499
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
Enable debugging of untitled script files #555
Comments
This change enables the debugging of untitled script files by executing their contents directly, not as a script file. Since the language server has already received the contents of the untitled file, we can easily access them in the server for execution purposes. Part of PowerShell/vscode-powershell#555.
This change enables untitled files to be debugged when they are set to the 'powershell' language mode. Fixes PowerShell#555.
VsCode Verion: 1.13.1 I'm sure this is me not understanding, but how do you do this type of debugging? I have a new untitled, unsaved file (language mode set to PowerShell) with a function defined and then a line that runs that function. When I press F5 it just runs everything without breaking into the debugger. I can't set a breakpoint because the file isn't saved so how do you go about debugging an untitled, unsaved file? |
ISE does not allow you to set a breakpoint in an unsaved file. The same applies to the VSCode PowerShell extension. Internally, it uses the You can set a command breakpoint and the debugger will hit that e.g.: function foo {}
foo
$a = 7
$b = 36
$c = 42 Set a command breakpoint on It would be nice if this feature supported a "break on entry" option. Then you wouldn't need the dummy function hack to get the debugger to break. That said, it can be challenging to debug without line breakpoints so it is best to just save the file. |
Wait a tic, if I hit the command breakpoint I see another editor window open that uses a temp (saved) file so you can set line breakpoints. The bug here @daviwil is that this |
Maybe I'm still doing this wrong but I still can't get it to break. I have the unsaved script file that, creates a dummy function called Edit: Ok, I can get it to break by setting the command breakpoint and then running the function from within the PowerShell Integrated Console rather than pressing F5. Only seems to work once as if I run the function again it doesn't break. It does if I set the breakpoint again. A "break on entry" option would be awesome for debugging simple test scripts that I'd rather not have to save. |
That worked. Thanks very much. |
VS Code will soon be gaining the ability to launch the debugger on untitled, unsaved files. Since this is a scenario that works in the ISE, we should leverage VS Code's new feature to provide it in the PowerShell extension too.
microsoft/vscode#19415
/cc @dfinke
The text was updated successfully, but these errors were encountered: