Skip to content

Commit 8ce4d5c

Browse files
codacy
1 parent ce6e88d commit 8ce4d5c

File tree

3 files changed

+5
-20
lines changed

3 files changed

+5
-20
lines changed

src/PowerShellEditorServices/Services/DebugAdapter/BreakpointService.cs

+2
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ public async Task RemoveBreakpointsAsync(IEnumerable<Breakpoint> breakpoints)
281281
bps.Remove(lineBreakpoint);
282282
}
283283
break;
284+
default:
285+
throw new ArgumentException("Unsupported breakpoint type.");
284286
}
285287
}
286288

src/PowerShellEditorServices/Services/DebugAdapter/DebugService.cs

+1-18
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public async Task<BreakpointDetails[]> SetLineBreakpointsAsync(
185185
{
186186
if (clearExisting)
187187
{
188-
await this.ClearBreakpointsInFileAsync(scriptFile).ConfigureAwait(false);
188+
await _breakpointService.RemoveAllBreakpointsAsync(scriptFile.FilePath).ConfigureAwait(false);
189189
}
190190

191191
return (await _breakpointService.SetBreakpointsAsync(escapedScriptPath, breakpoints).ConfigureAwait(false)).ToArray();
@@ -665,23 +665,6 @@ public VariableScope[] GetVariableScopes(int stackFrameId)
665665

666666
#region Private Methods
667667

668-
private async Task ClearBreakpointsInFileAsync(ScriptFile scriptFile)
669-
{
670-
// Get the list of breakpoints for this file
671-
// if (_breakpointService.BreakpointsPerFile.TryGetValue(scriptFile.Id, out HashSet<Breakpoint> breakpoints))
672-
// {
673-
// if (breakpoints.Count > 0)
674-
// {
675-
await _breakpointService.RemoveAllBreakpointsAsync(scriptFile.FilePath).ConfigureAwait(false);
676-
// await _breakpointService.RemoveBreakpointsAsync((await _breakpointService.GetBreakpointsAsync())
677-
// .Where(bp => bp is LineBreakpoint lbp && string.Equals(lbp.Script, scriptFile.FilePath))).ConfigureAwait(false);
678-
679-
// Clear the existing breakpoints list for the file
680-
// breakpoints.Clear();
681-
// }
682-
// }
683-
}
684-
685668
private async Task FetchStackFramesAndVariablesAsync(string scriptNameOverride)
686669
{
687670
await this.debugInfoHandle.WaitAsync().ConfigureAwait(false);

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,12 @@ public SetBreakpointsHandler(
142142
public async Task<SetBreakpointsResponse> Handle(SetBreakpointsArguments request, CancellationToken cancellationToken)
143143
{
144144
ScriptFile scriptFile = null;
145+
bool isUntitledPath = ScriptFile.IsUntitledPath(request.Source.Path);
145146

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

163164
// Verify source file is a PowerShell script file.
164165
string fileExtension = Path.GetExtension(scriptFile?.FilePath ?? "")?.ToLower();
165-
bool isUntitledPath = ScriptFile.IsUntitledPath(request.Source.Path);
166166
if ((!isUntitledPath && fileExtension != ".ps1" && fileExtension != ".psm1") ||
167167
(!BreakpointApiUtils.SupportsBreakpointApis && isUntitledPath))
168168
{

0 commit comments

Comments
 (0)