Skip to content

Fix logic checking for untitled or raw scripts #1839

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 1 commit into from
Jun 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,13 @@ public Task<ConfigurationDoneResponse> Handle(ConfigurationDoneArguments request
private async Task LaunchScriptAsync(string scriptToLaunch)
{
PSCommand command;
// Script could an actual script, or a URI to a script file (or untitled document).
if (!System.Uri.IsWellFormedUriString(scriptToLaunch, System.UriKind.RelativeOrAbsolute)
|| ScriptFile.IsUntitledPath(scriptToLaunch))
if (System.IO.File.Exists(scriptToLaunch))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is going to break for remote files (e.g. you do an interactive Enter-PSSession and then psedit ./something.ps1) but that's also probably super broken atm anyway. Something we should revisit in the future, but definitely not a blocker to getting this fixed

{
// For a saved file we just execute its path (after escaping it).
command = PSCommandHelpers.BuildDotSourceCommandWithArguments(
string.Concat('"', scriptToLaunch, '"'), _debugStateService.Arguments);
}
else // It's a URI to an untitled script, or a raw script.
{
bool isScriptFile = _workspaceService.TryGetFile(scriptToLaunch, out ScriptFile untitledScript);
if (isScriptFile && BreakpointApiUtils.SupportsBreakpointApis(_runspaceContext.CurrentRunspace))
Expand Down Expand Up @@ -147,12 +151,6 @@ private async Task LaunchScriptAsync(string scriptToLaunch)
_debugStateService.Arguments);
}
}
else
{
// For a saved file we just execute its path (after escaping it).
command = PSCommandHelpers.BuildDotSourceCommandWithArguments(
string.Concat('"', scriptToLaunch, '"'), _debugStateService.Arguments);
}

await _executionService.ExecutePSCommandAsync(
command,
Expand Down