Skip to content

Commit a29dd3c

Browse files
misc feedback
1 parent 9f3cf01 commit a29dd3c

File tree

5 files changed

+11
-16
lines changed

5 files changed

+11
-16
lines changed

src/PowerShellEditorServices/Services/DebugAdapter/DebugService.cs

-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@
1414
using Microsoft.PowerShell.EditorServices.Utility;
1515
using System.Threading;
1616
using Microsoft.Extensions.Logging;
17-
using Microsoft.PowerShell.EditorServices.Logging;
1817
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
1918
using Microsoft.PowerShell.EditorServices.Services.PowerShellContext;
2019
using Microsoft.PowerShell.EditorServices.Services.DebugAdapter;
21-
using System.Collections.Concurrent;
2220

2321
namespace Microsoft.PowerShell.EditorServices.Services
2422
{

src/PowerShellEditorServices/Services/DebugAdapter/Handlers/BreakpointHandlers.cs

+2-7
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,7 @@ public SetBreakpointsHandler(
141141

142142
public async Task<SetBreakpointsResponse> Handle(SetBreakpointsArguments request, CancellationToken cancellationToken)
143143
{
144-
ScriptFile scriptFile = null;
145-
bool isUntitledPath = ScriptFile.IsUntitledPath(request.Source.Path);
146-
147-
// When you set a breakpoint in the right pane of a Git diff window on a PS1 file,
148-
// the Source.Path comes through as Untitled-X. That's why we check for IsUntitledPath.
149-
if (!_workspaceService.TryGetFile(request.Source.Path, out scriptFile) &&
150-
!isUntitledPath)
144+
if (!_workspaceService.TryGetFile(request.Source.Path, out ScriptFile scriptFile))
151145
{
152146
string message = _debugStateService.NoDebug ? string.Empty : "Source file could not be accessed, breakpoint not set.";
153147
var srcBreakpoints = request.Breakpoints
@@ -163,6 +157,7 @@ public async Task<SetBreakpointsResponse> Handle(SetBreakpointsArguments request
163157

164158
// Verify source file is a PowerShell script file.
165159
string fileExtension = Path.GetExtension(scriptFile?.FilePath ?? "")?.ToLower();
160+
bool isUntitledPath = ScriptFile.IsUntitledPath(request.Source.Path);
166161
if ((!isUntitledPath && fileExtension != ".ps1" && fileExtension != ".psm1") ||
167162
(!BreakpointApiUtils.SupportsBreakpointApis && isUntitledPath))
168163
{

src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
using OmniSharp.Extensions.DebugAdapter.Protocol.Events;
1717
using MediatR;
1818
using OmniSharp.Extensions.JsonRpc;
19+
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
1920

2021
namespace Microsoft.PowerShell.EditorServices.Handlers
2122
{
@@ -183,7 +184,13 @@ public async Task<Unit> Handle(PsesLaunchRequestArguments request, CancellationT
183184
_debugStateService.Arguments = arguments;
184185
_debugStateService.IsUsingTempIntegratedConsole = request.CreateTemporaryIntegratedConsole;
185186

186-
// TODO: Bring this back
187+
if (request.CreateTemporaryIntegratedConsole
188+
&& !string.IsNullOrEmpty(request.Script)
189+
&& ScriptFile.IsUntitledPath(request.Script))
190+
{
191+
throw new RpcErrorException(0, "Running an Untitled file in a temporary integrated console is currently not supported.");
192+
}
193+
187194
// If the current session is remote, map the script path to the remote
188195
// machine if necessary
189196
if (_debugStateService.ScriptToLaunch != null &&

src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class PowerShellContextService : IDisposable, IHostSupportsInteractiveSes
4646
static PowerShellContextService()
4747
{
4848
// PowerShell ApartmentState APIs aren't available in PSStandard, so we need to use reflection
49-
if (!VersionUtils.IsNetCore || VersionUtils.IsPS7)
49+
if (!VersionUtils.IsNetCore || VersionUtils.IsPS7OrGreater)
5050
{
5151
MethodInfo setterInfo = typeof(Runspace).GetProperty("ApartmentState").GetSetMethod();
5252
Delegate setter = Delegate.CreateDelegate(typeof(Action<Runspace, ApartmentState>), firstArgument: null, method: setterInfo);

src/PowerShellEditorServices/Utility/VersionUtils.cs

-5
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ internal static class VersionUtils
4444
/// </summary>
4545
public static bool IsPS6 { get; } = PSVersion.Major == 6;
4646

47-
/// <summary>
48-
/// True if we are running in PowerShell 7, false otherwise.
49-
/// </summary>
50-
public static bool IsPS7 { get; } = PSVersion.Major == 7;
51-
5247
/// <summary>
5348
/// True if we are running in PowerShell 7, false otherwise.
5449
/// </summary>

0 commit comments

Comments
 (0)