Skip to content

Commit caa7fb3

Browse files
committed
Switch StepBack to restartFrame
Fixes #2171.
1 parent 0651356 commit caa7fb3

7 files changed

Lines changed: 18 additions & 23 deletions

File tree

‎package.json‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,12 +1496,6 @@
14961496
"description": "Whether to perform hot-reload-on-save based on a filesystem watcher for Dart files rather than using VS Code's onDidSave event. This allows reloads to trigger when external tools modify Dart source files.",
14971497
"scope": "window"
14981498
},
1499-
"dart.previewDebuggerStepBack": {
1500-
"type": "boolean",
1501-
"default": false,
1502-
"description": "Whether to enable the debuggers 'Step Back' functionality. This is behind a flag while VS Code does not support enabling it separately to the 'Reverse Continue' button.",
1503-
"scope": "window"
1504-
},
15051499
"dart.previewNewCompletionPlaceholders": {
15061500
"type": "boolean",
15071501
"default": true,

‎src/debug/dart_debug_impl.ts‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as fs from "fs";
22
import * as path from "path";
3-
import { CapabilitiesEvent, DebugSession, Event, InitializedEvent, OutputEvent, Scope, Source, StackFrame, StoppedEvent, TerminatedEvent } from "vscode-debugadapter";
3+
import { DebugSession, Event, InitializedEvent, OutputEvent, Scope, Source, StackFrame, StoppedEvent, TerminatedEvent } from "vscode-debugadapter";
44
import { DebugProtocol } from "vscode-debugprotocol";
55
import { config } from "../extension/config";
66
import { notUndefined } from "../extension/utils";
@@ -98,6 +98,7 @@ export class DartDebugSession extends DebugSession {
9898
response.body.supportsConditionalBreakpoints = true;
9999
response.body.supportsLogPoints = true;
100100
response.body.supportsTerminateRequest = true;
101+
response.body.supportsRestartFrame = true;
101102
response.body.exceptionBreakpointFilters = [
102103
{ filter: "All", label: "All Exceptions", default: false },
103104
{ filter: "Unhandled", label: "Uncaught Exceptions", default: true },
@@ -140,9 +141,6 @@ export class DartDebugSession extends DebugSession {
140141
this.logFile = args.observatoryLogFile;
141142
this.maxLogLineLength = args.maxLogLineLength;
142143

143-
if (args.previewDebuggerStepBack)
144-
this.sendEvent(new CapabilitiesEvent({ supportsStepBack: true }));
145-
146144
this.sendResponse(response);
147145

148146
this.childProcess = this.spawnProcess(args);
@@ -1093,15 +1091,21 @@ export class DartDebugSession extends DebugSession {
10931091
}).catch((error) => this.errorResponse(response, `${error}`));
10941092
}
10951093

1096-
protected stepBackRequest(response: DebugProtocol.StepBackResponse, args: DebugProtocol.StepBackArguments): void {
1097-
const thread = this.threadManager.getThreadInfoFromNumber(args.threadId);
1098-
if (!thread) {
1099-
this.errorResponse(response, `No thread with id ${args.threadId}`);
1094+
protected restartFrameRequest(response: DebugProtocol.RestartFrameResponse, args: DebugProtocol.RestartFrameArguments): void {
1095+
const frameId = args.frameId;
1096+
// const context: string = args.context; // "watch", "repl", "hover"
1097+
1098+
if (!frameId) {
1099+
this.errorResponse(response, "global evaluation not supported");
11001100
return;
11011101
}
1102-
thread.resume("Rewind").then((_) => {
1102+
1103+
const data = this.threadManager.getStoredData(frameId);
1104+
const thread = data.thread;
1105+
const frame: VMFrame = data.data as VMFrame;
1106+
1107+
thread.resume("Rewind", frame.index).then((_) => {
11031108
this.sendResponse(response);
1104-
this.requestCoverageUpdate("rewind");
11051109
}).catch((error) => this.errorResponse(response, `${error}`));
11061110
}
11071111

‎src/debug/dart_debug_protocol.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,8 @@ export class ObservatoryConnection {
451451
}
452452

453453
// Into, Over, OverAsyncSuspension, and Out
454-
public resume(isolateId: string, step?: string): Promise<DebuggerResult> {
455-
return this.callMethod("resume", { isolateId, step });
454+
public resume(isolateId: string, step?: string, frameIndex?: number): Promise<DebuggerResult> {
455+
return this.callMethod("resume", { isolateId, step, frameIndex });
456456
}
457457

458458
public getStack(isolateId: string): Promise<DebuggerResult> {

‎src/debug/threads.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,13 +313,13 @@ export class ThreadInfo {
313313
this.paused = false;
314314
}
315315

316-
public async resume(step?: string): Promise<void> {
316+
public async resume(step?: string, frameIndex?: number): Promise<void> {
317317
if (!this.paused || this.hasPendingResume || !this.manager.debugSession.observatory)
318318
return;
319319

320320
this.hasPendingResume = true;
321321
try {
322-
await this.manager.debugSession.observatory.resume(this.ref.id, step);
322+
await this.manager.debugSession.observatory.resume(this.ref.id, step, frameIndex);
323323
this.handleResumed();
324324
} finally {
325325
this.hasPendingResume = false;

‎src/debug/utils.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ export interface DartLaunchRequestArguments extends DebugProtocol.LaunchRequestA
4747
pubSnapshotPath: string;
4848
pubTestLogFile?: string;
4949
showMemoryUsage: boolean;
50-
previewDebuggerStepBack: boolean;
5150
}
5251

5352
export interface FlutterLaunchRequestArguments extends DartLaunchRequestArguments {

‎src/extension/config.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ class Config {
8080
get openDevTools(): "never" | "flutter" | "always" { return this.getConfig<"never" | "flutter" | "always">("openDevTools", "never"); }
8181
get openTestView(): Array<"testRunStart" | "testFailure"> { return this.getConfig<Array<"testRunStart" | "testFailure">>("openTestView", ["testRunStart"]); }
8282
get previewBuildRunnerTasks(): boolean { return this.getConfig<boolean>("previewBuildRunnerTasks", false); }
83-
get previewDebuggerStepBack(): boolean { return this.getConfig<boolean>("previewDebuggerStepBack", false); }
8483
get previewFlutterUiGuides(): boolean { return this.getConfig<boolean>("previewFlutterUiGuides", false); }
8584
get previewFlutterUiGuidesCustomTracking(): boolean { return this.getConfig<boolean>("previewFlutterUiGuidesCustomTracking", false); }
8685
get previewHotReloadOnSaveWatcher(): boolean { return this.getConfig<boolean>("previewHotReloadOnSaveWatcher", false); }

‎src/extension/providers/debug_config_provider.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@ export class DebugConfigProvider implements DebugConfigurationProvider {
467467
? debugConfig.debuggerHandlesPathsEverywhereForBreakpoints
468468
: this.dartCapabilities.handlesPathsEverywhereForBreakpoints;
469469
debugConfig.evaluateGettersInDebugViews = debugConfig.evaluateGettersInDebugViews || conf.evaluateGettersInDebugViews;
470-
debugConfig.previewDebuggerStepBack = config.previewDebuggerStepBack;
471470
if (isFlutter && this.sdks.flutter) {
472471
debugConfig.args = conf.flutterAdditionalArgs.concat(debugConfig.args);
473472
debugConfig.forceFlutterVerboseMode = isLogging || isCI;

0 commit comments

Comments
 (0)