提交 c6c9d5b4 编写于 作者: I isidor

debug: more precise computatino of top stack frame call stack decoration

上级 e3a0f6a9
......@@ -48,8 +48,8 @@ export function createDecorationsForStackFrame(stackFrame: IStackFrame, topStack
// compute how to decorate the editor. Different decorations are used if this is a top stack frame, focused stack frame,
// an exception or a stack frame that did not change the line number (we only decorate the columns, not the whole line).
const callStack = stackFrame.thread.getCallStack();
if (callStack && callStack.length && stackFrame === callStack[0]) {
const topStackFrame = stackFrame.thread.getTopStackFrame();
if (stackFrame.getId() === topStackFrame?.getId()) {
result.push({
options: TOP_STACK_FRAME_MARGIN,
range
......
......@@ -6,7 +6,7 @@
import * as nls from 'vs/nls';
import { Event, Emitter } from 'vs/base/common/event';
import { URI as uri } from 'vs/base/common/uri';
import { first, distinct } from 'vs/base/common/arrays';
import { distinct } from 'vs/base/common/arrays';
import * as errors from 'vs/base/common/errors';
import severity from 'vs/base/common/severity';
import * as aria from 'vs/base/browser/ui/aria/aria';
......@@ -991,11 +991,8 @@ export function getStackFrameThreadAndSessionToFocus(model: IDebugModel, stackFr
}
}
if (!stackFrame) {
if (thread) {
const callStack = thread.getCallStack();
stackFrame = first(callStack, sf => !!(sf && sf.source && sf.source.available && sf.source.presentationHint !== 'deemphasize'), undefined);
}
if (!stackFrame && thread) {
stackFrame = thread.getTopStackFrame();
}
return { session, thread, stackFrame };
......
......@@ -288,6 +288,12 @@ export interface IThread extends ITreeElement {
*/
getCallStack(): ReadonlyArray<IStackFrame>;
/**
* Gets the top stack frame that is not hidden if the callstack has already been received from the debug adapter
*/
getTopStackFrame(): IStackFrame | undefined;
/**
* Invalidates the callstack cache
*/
......
......@@ -10,7 +10,7 @@ import { Event, Emitter } from 'vs/base/common/event';
import { generateUuid } from 'vs/base/common/uuid';
import { RunOnceScheduler } from 'vs/base/common/async';
import { isString, isUndefinedOrNull } from 'vs/base/common/types';
import { distinct, lastIndex } from 'vs/base/common/arrays';
import { distinct, lastIndex, first } from 'vs/base/common/arrays';
import { Range, IRange } from 'vs/editor/common/core/range';
import {
ITreeElement, IExpression, IExpressionContainer, IDebugSession, IStackFrame, IExceptionBreakpoint, IBreakpoint, IFunctionBreakpoint, IDebugModel,
......@@ -398,6 +398,10 @@ export class Thread implements IThread {
return this.staleCallStack;
}
getTopStackFrame(): IStackFrame | undefined {
return first(this.getCallStack(), sf => !!(sf && sf.source && sf.source.available && sf.source.presentationHint !== 'deemphasize'), undefined);
}
get stateLabel(): string {
if (this.stoppedDetails) {
return this.stoppedDetails.description ||
......
......@@ -42,8 +42,8 @@ function createTwoStackFrames(session: DebugSession): { firstStackFrame: StackFr
sourceReference: 11,
}, 'aDebugSessionId');
firstStackFrame = new StackFrame(thread, 1, firstSource, 'app.js', 'normal', { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 10 }, 1);
secondStackFrame = new StackFrame(thread, 1, secondSource, 'app.js', 'normal', { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 10 }, 1);
firstStackFrame = new StackFrame(thread, 0, firstSource, 'app.js', 'normal', { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 10 }, 0);
secondStackFrame = new StackFrame(thread, 1, secondSource, 'app2.js', 'normal', { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 10 }, 1);
return { firstStackFrame, secondStackFrame };
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册