Skip to content

Commit b995df2

Browse files
committed
debug: Breaking should jump to top frame that has source
fixes microsoft#64193
1 parent 17bf945 commit b995df2

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

src/vs/workbench/parts/debug/common/debug.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ export interface IDebugModel extends ITreeElement {
393393
getWatchExpressions(): ReadonlyArray<IExpression & IEvaluate>;
394394

395395
onDidChangeBreakpoints: Event<IBreakpointsChangeEvent>;
396-
onDidChangeCallStack: Event<void>;
396+
onDidChangeCallStack: Event<IThread | undefined>;
397397
onDidChangeWatchExpressions: Event<IExpression>;
398398
}
399399

src/vs/workbench/parts/debug/common/debugModel.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ export class DebugModel implements IDebugModel {
737737
private schedulers = new Map<string, RunOnceScheduler>();
738738
private breakpointsSessionId: string;
739739
private readonly _onDidChangeBreakpoints: Emitter<IBreakpointsChangeEvent>;
740-
private readonly _onDidChangeCallStack: Emitter<void>;
740+
private readonly _onDidChangeCallStack: Emitter<IThread | undefined>;
741741
private readonly _onDidChangeWatchExpressions: Emitter<IExpression>;
742742

743743
constructor(
@@ -751,7 +751,7 @@ export class DebugModel implements IDebugModel {
751751
this.sessions = [];
752752
this.toDispose = [];
753753
this._onDidChangeBreakpoints = new Emitter<IBreakpointsChangeEvent>();
754-
this._onDidChangeCallStack = new Emitter<void>();
754+
this._onDidChangeCallStack = new Emitter<IThread | undefined>();
755755
this._onDidChangeWatchExpressions = new Emitter<IExpression>();
756756
}
757757

@@ -786,7 +786,7 @@ export class DebugModel implements IDebugModel {
786786
return this._onDidChangeBreakpoints.event;
787787
}
788788

789-
get onDidChangeCallStack(): Event<void> {
789+
get onDidChangeCallStack(): Event<IThread | undefined> {
790790
return this._onDidChangeCallStack.event;
791791
}
792792

@@ -819,12 +819,12 @@ export class DebugModel implements IDebugModel {
819819
return thread.fetchCallStack(1).then(() => {
820820
if (!this.schedulers.has(thread.getId())) {
821821
this.schedulers.set(thread.getId(), new RunOnceScheduler(() => {
822-
thread.fetchCallStack(19).then(() => this._onDidChangeCallStack.fire());
822+
thread.fetchCallStack(19).then(() => this._onDidChangeCallStack.fire(thread));
823823
}, 420));
824824
}
825825

826826
this.schedulers.get(thread.getId()).schedule();
827-
this._onDidChangeCallStack.fire();
827+
this._onDidChangeCallStack.fire(thread);
828828
});
829829
}
830830

src/vs/workbench/parts/debug/electron-browser/debugSession.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,16 @@ export class DebugSession implements IDebugSession {
611611
this.model.fetchCallStack(<Thread>thread).then(() => {
612612
if (!event.body.preserveFocusHint && thread.getCallStack().length) {
613613
this.debugService.focusStackFrame(undefined, thread);
614+
if (!this.debugService.getViewModel().focusedStackFrame) {
615+
// There were no appropriate stack frames to focus.
616+
// We need to listen on additional stack frame fetching and try to refocus #65012
617+
const listener = this.model.onDidChangeCallStack(t => {
618+
if (t && t.getId() === thread.getId()) {
619+
dispose(listener);
620+
this.debugService.focusStackFrame(undefined, thread);
621+
}
622+
});
623+
}
614624
if (thread.stoppedDetails) {
615625
if (this.configurationService.getValue<IDebugConfiguration>('debug').openDebug === 'openOnDebugBreak') {
616626
this.viewletService.openViewlet(VIEWLET_ID);

0 commit comments

Comments
 (0)