Skip to content

Fix detection of valid PS ext for debugging. #642

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

Merged
merged 4 commits into from
Apr 2, 2017

Conversation

rkeithhill
Copy link
Contributor

Was previously only allowing lower case ps1 and psm1. I'm assuming that on *nix file systems, that PowerShell allows all variations of ps1,PS1,pS1,Ps1 as valid script extensions.

Fix #641

@daviwil Currently, debugging an "untitled" script file doesn't work even if you set the language to PowerShell. That's because this code below detects "isUntitled" and sets the script property to untitled:Untitled-1. Seems like you were working on enabling debug of untitled/unsaved script files. Is that coming later or should the below be working now?

Was previously only allowing lower case ps1 and psm1.  I'm assuming that on *nix file systems, that PowerShell allows all variations of ps1,PS1,pS1,Ps1 as valid script extensions.

Fix #641
@rkeithhill rkeithhill added this to the Next Patch Update milestone Apr 1, 2017
@rkeithhill rkeithhill requested a review from daviwil April 1, 2017 21:28
@daviwil
Copy link
Contributor

daviwil commented Apr 2, 2017

@rkeithhill have you updated your PSES? I did the debug adapter work already to enable this. If it's not working after updating that I may need to take a look. Has been working fine for me though.

@daviwil daviwil modified the milestones: 0.12.0, Next Patch Update Apr 2, 2017
@daviwil
Copy link
Contributor

daviwil commented Apr 2, 2017

Setting the script property to the URI is intentional, the language server already has the contents of a file with that URI so I detect that in the debug adapter and load the file contents from the current workspace.

@daviwil
Copy link
Contributor

daviwil commented Apr 2, 2017

Actually, approved too soon. I think we need to ensure the language mode is still powershell when the file is untitled, right? Not sure if the debug adapter client will still send us requests for untitled files that aren't marked as powershell.

@rkeithhill
Copy link
Contributor Author

rkeithhill commented Apr 2, 2017

Yeah I was wondering about that. You made that change to VSCode but I figured that wouldn't be released for a while. So the assumption was that this worked without having to set the language mode. So, let me check my understanding. You can debug an unsaved file but for now you have to set the language mode to PowerShell. Is that right? If that is the case, we can put up a message to tell the user to set the language mode to PowerShell for an unsaved doc.

@rkeithhill
Copy link
Contributor Author

rkeithhill commented Apr 2, 2017

What do you think?
image
BTW this makes sense but I want to double check. If the file is not saved you can run it from the debugger and break into the debugger and single step but you can't set breakpoints. Is that right?

Or since that hasn't been saved to file yet, maybe I should remove the "for the file" bit? We could even append on a "or save the file with a PowerShell extension."

@rkeithhill
Copy link
Contributor Author

Is this too verbose?
image

@daviwil
Copy link
Contributor

daviwil commented Apr 2, 2017

Hmm... Yeah, good point. I suppose if they've already selected the PowerShell debug configuration for Current File and they're hitting F5 on an untitled file that isn't marked powershell then presumably they'd want to debug it as PowerShell. However, if the file hasn't been sent to the language server already (which it wouldn't have if it isn't marked as powershell then we won't be able to debug it. I think having the error there makes sense.

Yeah, you won't be able to set breakpoints at this time with the untitled script, just stepping through.

@daviwil
Copy link
Contributor

daviwil commented Apr 2, 2017

Might be good to get @juneb's input on the error message string, she's been fixing up a lot of my bad verbiage :)

@rkeithhill
Copy link
Contributor Author

rkeithhill commented Apr 2, 2017

Sounds good to me. I just changed the "set the document's language mode" to "change the document's language mode" to better match the command entry in the command palette - "change language mode".
image
It might be nice to shorten this up a bit since it will get the ... treatment if the VSCode window is narrow.

@juneb
Copy link
Contributor

juneb commented Apr 2, 2017

Thanks, @daviwil! Change is much better than set, which is ambiguous, even to native English speakers.

To shorten that error message, change "In order to" to "To".

To debug '', change the document language mode to PowerShell or save the file with a PowerShell extension.

@rkeithhill
Copy link
Contributor Author

OK, updated to:
image
Thanks @juneb

@daviwil
Copy link
Contributor

daviwil commented Apr 2, 2017

Looks good, thanks June!

@rkeithhill rkeithhill merged commit 18ca702 into develop Apr 2, 2017
@rkeithhill rkeithhill deleted the rkeithhill/is641-fix-fileext-comparison branch April 2, 2017 03:30
rkeithhill referenced this pull request Apr 2, 2017
This change enables untitled files to be debugged when they are set to the
'powershell' language mode.

Fixes #555.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants