提交 bb194502 编写于 作者: I isidor

debug: do not rely on focused session when updating viewlet

上级 c4da8456
......@@ -354,6 +354,7 @@ export class CallStackDataSource implements tree.IDataSource {
}
public hasChildren(tree: tree.ITree, element: any): boolean {
// TODO@isidor also has children if it is a session
return element instanceof model.Model || (element instanceof model.Thread && (<model.Thread>element).stopped);
}
......@@ -361,14 +362,12 @@ export class CallStackDataSource implements tree.IDataSource {
if (element instanceof model.Thread) {
return this.getThreadChildren(element);
}
// TODO@Isidor FIX THIS
const session = this.debugService.getViewModel().activeSession;
if (!session) {
return TPromise.as([]);
if (element instanceof model.Model) {
return TPromise.as(element.getSessions());
}
const threads = (<model.Model>element).getThreads(session.getId());
const session = <debug.IRawDebugSession>element;
const threads = this.debugService.getModel().getThreads(session.getId());
return TPromise.as(Object.keys(threads).map(ref => threads[ref]));
}
......
......@@ -290,11 +290,14 @@ export class CallStackView extends viewlet.CollapsibleViewletView {
}));
this.toDispose.push(model.onDidChangeCallStack(() => {
const session = this.debugService.getViewModel().activeSession;
const threads = session ? model.getThreads(session.getId()) : Object.create(null);
const threadsArray = Object.keys(threads).map(ref => threads[ref]);
// Only show the threads in the call stack if there is more than 1 thread.
const newTreeInput = threadsArray.length === 1 ? threadsArray[0] : model;
let newTreeInput: any = this.debugService.getModel();
const sessions = this.debugService.getModel().getSessions();
if (sessions.length === 1) {
const threads = sessions[0] ? model.getThreads(sessions[0].getId()) : Object.create(null);
const threadsArray = Object.keys(threads).map(ref => threads[ref]);
// Only show the threads in the call stack if there is more than 1 thread.
newTreeInput = threadsArray.length === 1 ? threadsArray[0] : sessions[0];
}
if (this.tree.getInput() === newTreeInput) {
this.tree.refresh().done(null, errors.onUnexpectedError);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册