提交 97f7bdd6 编写于 作者: I isidor

debug: allow to set focussed thread with no call stack

fixes #6214
上级 f2baddbf
......@@ -134,13 +134,14 @@ export class DebugEditorModelManager implements IWorkbenchContribution {
private createCallStackDecorations(modelUrlStr: string): editorcommon.IModelDeltaDecoration[] {
const result: editorcommon.IModelDeltaDecoration[] = [];
const focusedStackFrame = this.debugService.getViewModel().getFocusedStackFrame();
const focusedThreadId = this.debugService.getViewModel().getFocusedThreadId();
const allThreads = this.debugService.getModel().getThreads();
if (!focusedStackFrame || !allThreads[focusedStackFrame.threadId] || !allThreads[focusedStackFrame.threadId].getCachedCallStack()) {
if (!focusedStackFrame || !allThreads[focusedThreadId] || !allThreads[focusedThreadId].getCachedCallStack()) {
return result;
}
// only show decorations for the currently focussed thread.
const thread = allThreads[focusedStackFrame.threadId];
const thread = allThreads[focusedThreadId];
thread.getCachedCallStack().filter(sf => sf.source.uri.toString() === modelUrlStr).forEach(sf => {
const wholeLineRange = createRange(sf.lineNumber, sf.column, sf.lineNumber, Number.MAX_VALUE);
......
......@@ -9,6 +9,7 @@ import debug = require('vs/workbench/parts/debug/common/debug');
export class ViewModel implements debug.IViewModel {
private focusedStackFrame: debug.IStackFrame;
private focusedThread: debug.IThread;
private selectedExpression: debug.IExpression;
private selectedFunctionBreakpoint: debug.IFunctionBreakpoint;
private _onDidFocusStackFrame: Emitter<debug.IStackFrame>;
......@@ -31,8 +32,9 @@ export class ViewModel implements debug.IViewModel {
return this.focusedStackFrame;
}
public setFocusedStackFrame(focusedStackFrame: debug.IStackFrame): void {
public setFocusedStackFrame(focusedStackFrame: debug.IStackFrame, focusedThread: debug.IThread): void {
this.focusedStackFrame = focusedStackFrame;
this.focusedThread = focusedThread;
this._onDidFocusStackFrame.fire(focusedStackFrame);
}
......@@ -41,7 +43,7 @@ export class ViewModel implements debug.IViewModel {
}
public getFocusedThreadId(): number {
return this.focusedStackFrame ? this.focusedStackFrame.threadId : 0;
return this.focusedThread ? this.focusedThread.threadId : 0;
}
public getSelectedExpression(): debug.IExpression {
......
......@@ -251,17 +251,18 @@ export class DebugService implements debug.IDebugService {
allThreadsStopped: event.body.allThreadsStopped
});
this.model.getThreads()[threadId].getCallStack(this).then(callStack => {
const thread = this.model.getThreads()[threadId];
thread.getCallStack(this).then(callStack => {
if (callStack.length > 0) {
// focus first stack frame from top that has source location
const stackFrameToFocus = arrays.first(callStack, sf => sf.source && sf.source.available, callStack[0]);
this.setFocusedStackFrameAndEvaluate(stackFrameToFocus).done(null, errors.onUnexpectedError);
this.setFocusedStackFrameAndEvaluate(stackFrameToFocus, thread).done(null, errors.onUnexpectedError);
this.windowService.getWindow().focus();
aria.alert(nls.localize('debuggingPaused', "Debugging paused, reason {0}, {1} {2}", event.body.reason, stackFrameToFocus.source ? stackFrameToFocus.source.name : '', stackFrameToFocus.lineNumber));
return this.openOrRevealSource(stackFrameToFocus.source, stackFrameToFocus.lineNumber, false, false);
} else {
this.setFocusedStackFrameAndEvaluate(null).done(null, errors.onUnexpectedError);
this.setFocusedStackFrameAndEvaluate(null, thread).done(null, errors.onUnexpectedError);
}
});
}, errors.onUnexpectedError);
......@@ -394,8 +395,12 @@ export class DebugService implements debug.IDebugService {
return !!this.contextService.getWorkspace();
}
public setFocusedStackFrameAndEvaluate(focusedStackFrame: debug.IStackFrame): TPromise<void> {
this.viewModel.setFocusedStackFrame(focusedStackFrame);
public setFocusedStackFrameAndEvaluate(focusedStackFrame: debug.IStackFrame, thread?: debug.IThread): TPromise<void> {
if (!thread && focusedStackFrame) {
thread = this.model.getThreads()[focusedStackFrame.threadId];
}
this.viewModel.setFocusedStackFrame(focusedStackFrame, thread);
if (focusedStackFrame) {
return this.model.evaluateWatchExpressions(this.session, focusedStackFrame);
} else {
......
......@@ -5,7 +5,7 @@
import assert = require('assert');
import { ViewModel } from 'vs/workbench/parts/debug/common/debugViewModel';
import { StackFrame, Expression } from 'vs/workbench/parts/debug/common/debugModel';
import { StackFrame, Expression, Thread } from 'vs/workbench/parts/debug/common/debugModel';
suite('Debug - View Model', () => {
var model: ViewModel;
......@@ -22,7 +22,7 @@ suite('Debug - View Model', () => {
assert.equal(model.getFocusedStackFrame(), null);
assert.equal(model.getFocusedThreadId(), 0);
const frame = new StackFrame(1, 1, null, 'app.js', 1, 1);
model.setFocusedStackFrame(frame);
model.setFocusedStackFrame(frame, new Thread('myThread', 1));
assert.equal(model.getFocusedStackFrame(), frame);
assert.equal(model.getFocusedThreadId(), 1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册