Skip to content

Commit

Permalink
misc feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerLeonhardt committed Feb 4, 2020
1 parent 9f3cf01 commit a29dd3c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
using Microsoft.PowerShell.EditorServices.Utility;
using System.Threading;
using Microsoft.Extensions.Logging;
using Microsoft.PowerShell.EditorServices.Logging;
using Microsoft.PowerShell.EditorServices.Services.TextDocument;
using Microsoft.PowerShell.EditorServices.Services.PowerShellContext;
using Microsoft.PowerShell.EditorServices.Services.DebugAdapter;
using System.Collections.Concurrent;

namespace Microsoft.PowerShell.EditorServices.Services
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,7 @@ internal class SetBreakpointsHandler : ISetBreakpointsHandler

public async Task<SetBreakpointsResponse> Handle(SetBreakpointsArguments request, CancellationToken cancellationToken)
{
ScriptFile scriptFile = null;
bool isUntitledPath = ScriptFile.IsUntitledPath(request.Source.Path);

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

// Verify source file is a PowerShell script file.
string fileExtension = Path.GetExtension(scriptFile?.FilePath ?? "")?.ToLower();
bool isUntitledPath = ScriptFile.IsUntitledPath(request.Source.Path);
if ((!isUntitledPath && fileExtension != ".ps1" && fileExtension != ".psm1") ||
(!BreakpointApiUtils.SupportsBreakpointApis && isUntitledPath))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using OmniSharp.Extensions.DebugAdapter.Protocol.Events;
using MediatR;
using OmniSharp.Extensions.JsonRpc;
using Microsoft.PowerShell.EditorServices.Services.TextDocument;

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

// TODO: Bring this back
if (request.CreateTemporaryIntegratedConsole
&& !string.IsNullOrEmpty(request.Script)
&& ScriptFile.IsUntitledPath(request.Script))
{
throw new RpcErrorException(0, "Running an Untitled file in a temporary integrated console is currently not supported.");
}

// If the current session is remote, map the script path to the remote
// machine if necessary
if (_debugStateService.ScriptToLaunch != null &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class PowerShellContextService : IDisposable, IHostSupportsInteractiveSes
static PowerShellContextService()
{
// PowerShell ApartmentState APIs aren't available in PSStandard, so we need to use reflection
if (!VersionUtils.IsNetCore || VersionUtils.IsPS7)
if (!VersionUtils.IsNetCore || VersionUtils.IsPS7OrGreater)
{
MethodInfo setterInfo = typeof(Runspace).GetProperty("ApartmentState").GetSetMethod();
Delegate setter = Delegate.CreateDelegate(typeof(Action<Runspace, ApartmentState>), firstArgument: null, method: setterInfo);
Expand Down
5 changes: 0 additions & 5 deletions src/PowerShellEditorServices/Utility/VersionUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ internal static class VersionUtils
/// </summary>
public static bool IsPS6 { get; } = PSVersion.Major == 6;

/// <summary>
/// True if we are running in PowerShell 7, false otherwise.
/// </summary>
public static bool IsPS7 { get; } = PSVersion.Major == 7;

/// <summary>
/// True if we are running in PowerShell 7, false otherwise.
/// </summary>
Expand Down

0 comments on commit a29dd3c

Please sign in to comment.