提交 4b463830 编写于 作者: I isidor

debug: if there is a thread running focusedThread should not be null

fixes #15165
上级 8ffed7ef
......@@ -10,6 +10,7 @@ export class ViewModel implements debug.IViewModel {
private _focusedStackFrame: debug.IStackFrame;
private _focusedProcess: debug.IProcess;
private _focusedThread: debug.IThread;
private selectedExpression: debug.IExpression;
private selectedFunctionBreakpoint: debug.IFunctionBreakpoint;
private _onDidFocusStackFrame: Emitter<debug.IStackFrame>;
......@@ -38,16 +39,17 @@ export class ViewModel implements debug.IViewModel {
}
public get focusedThread(): debug.IThread {
return this._focusedStackFrame ? this._focusedStackFrame.thread : null;
return this._focusedThread;
}
public get focusedStackFrame(): debug.IStackFrame {
return this._focusedStackFrame;
}
public setFocusedStackFrame(stackFrame: debug.IStackFrame, process: debug.IProcess): void {
public setFocusedStackFrame(stackFrame: debug.IStackFrame, thread: debug.IThread, process: debug.IProcess): void {
this._focusedStackFrame = stackFrame;
this._focusedProcess = process;
this._focusedThread = thread;
this._onDidFocusStackFrame.fire(stackFrame);
this._onDidFocusProcess.fire(process);
}
......
......@@ -445,13 +445,13 @@ export class DebugService implements debug.IDebugService {
if (!process) {
process = focusedStackFrame ? focusedStackFrame.thread.process : processes.length ? processes[0] : null;
}
if (process && !focusedStackFrame) {
const thread = process.getAllThreads().pop();
const callStack = thread ? thread.getCachedCallStack() : null;
const thread = focusedStackFrame ? focusedStackFrame.thread : (process ? process.getAllThreads().pop() : null);
if (thread && !focusedStackFrame) {
const callStack = thread.getCachedCallStack();
focusedStackFrame = callStack && callStack.length ? callStack[0] : null;
}
this.viewModel.setFocusedStackFrame(focusedStackFrame, process);
this.viewModel.setFocusedStackFrame(focusedStackFrame, thread, process);
this._onDidChangeState.fire();
return this.model.evaluateWatchExpressions(process, focusedStackFrame);
......@@ -645,7 +645,7 @@ export class DebugService implements debug.IDebugService {
this.viewModel.setMultiProcessView(true);
}
if (!this.viewModel.focusedProcess) {
this.viewModel.setFocusedStackFrame(null, process);
this.viewModel.setFocusedStackFrame(null, null, process);
this._onDidChangeState.fire();
}
this.toDisposeOnSessionEnd[session.getId()] = [];
......
......@@ -26,7 +26,7 @@ suite('Debug - View Model', () => {
const process = new Process('mockProcess', mockSession);
const thread = new Thread(process, 'myThread', 1);
const frame = new StackFrame(thread, 1, null, 'app.js', 1, 1);
model.setFocusedStackFrame(frame, process);
model.setFocusedStackFrame(frame, thread, process);
assert.equal(model.focusedStackFrame, frame);
assert.equal(model.focusedThread.threadId, 1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册