- 
                Notifications
    You must be signed in to change notification settings 
- Fork 240
Fix running untitled scripts with arguments (but break line breakpoints) #1702
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
Conversation
        
          
                src/PowerShellEditorServices/Services/DebugAdapter/Handlers/ConfigurationDoneHandler.cs
              
                Outdated
          
            Show resolved
            Hide resolved
        
      83c078c    to
    62f81c8      
    Compare
  
    | This essentially reverts #1611 and stops attempting to quote arguments given to the script launcher. | 
5687a9e    to
    13b5cbb      
    Compare
  
    There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. RIP argumentescapingtests 🪦
Attempting to be "helpful" by escaping arguments proved to cause more issues than it solved. We can instead massively simplify our script launching logic (and fix yet another test that had a "maybe bug") by just launching what the user gave us. This should also be easier for the user to debug.
The extant hack that enabled line breakpoints in untitled scripts is
untenable. It shifted the user's args by one since it ran the untitled
script as the first arg to an inline script `. $args[0]` with `$args[0]`
being the script contents, instead of the expected `.  {<script>}`. This
hack that conflicted with the correct passing of arguments to the
debugged script. We are prioritizing the latter over the former, as
command breakpoints and `Wait-Debugger` work as expected, and the extant
behavior was rather unique (and unexpected) in the world of VS Code
extensions, to the point that the extension can now automatically prompt
to save untitled files.
    Since the pipeline rewrite, it is no longer necessary for the `ConfigurationDoneHandler` to manually start the debug loop when temporary consoles are created for debug sessions. Because of this, we can stop plumbing this information all the way through from the top.
13b5cbb    to
    29b56ce      
    Compare
  
    | darn :( I really liked untitled script debugging | 
| You can still debug it, just not with line breakpoints. We cannot support both that and passing arguments to the script.  | 
| @andschwa Also, I reverted to the previous version of the Preview extension and I'm not able to perform 'untitled script debugging'. This is the code I'm using: What I'm missing? What is the latest extension version that has this feature enabled? | 
| @ALIENQuake We are indeed looking to see if we can keep both behaviors. We don't want to keep the hack that previously supported the feature, but are trying to find a way to do it in a less hacky manner. Thing is, in my experience the line breakpoints were frequently off by one in untitled files because it was not a file being passed but the parsed AST. | 
| The fix for this is out in PowerShell Preview! Line breakpoints were re-enabled and arguments are supported! Please note that the code that's run looks funky ('cause it is) but it works! | 
| @andschwa Wonderfull! Many thanks for your extra effort 👍🏻 EDIT: It works only on PowerShell 6+, it's by design? Not that it's any problem for me, just asking. | 
| To be totally clear I would say in PowerShell 7+ by design (where the APIs to do this are available). PowerShell 6 isn't supported by us or even by itself any more 😉 | 
So the extant hack that enabled debugging untitled scripts is really
untenable. It shifted the user's args by one since it ran the untitled
script as the first arg to the dot-source operator. Unfortunately, there
doesn't seem to be a clear way to break on lines in an untitled script.
However,
Wait-Debuggerand command breakpoints should still work.Fixes PowerShell/vscode-powershell#3655
Fixes PowerShell/vscode-powershell#3770