debug: always show top call stack column

fixes #119485
This commit is contained in:
isidor 2021-03-29 11:03:06 +02:00
parent 01e844e75d
commit f554a74550
No known key found for this signature in database
GPG key ID: F9280366A8370105
2 changed files with 11 additions and 15 deletions

View file

@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { Constants } from 'vs/base/common/uint';
import { Range, IRange } from 'vs/editor/common/core/range';
import { Range } from 'vs/editor/common/core/range';
import { TrackedRangeStickiness, IModelDeltaDecoration, IModelDecorationOptions, OverviewRulerLane } from 'vs/editor/common/model';
import { IDebugService, IStackFrame } from 'vs/workbench/contrib/debug/common/debug';
import { registerThemingParticipant, themeColorFromId, ThemeIcon } from 'vs/platform/theme/common/themeService';
@ -53,7 +53,7 @@ const FOCUSED_STACK_FRAME_DECORATION: IModelDecorationOptions = {
stickiness
};
export function createDecorationsForStackFrame(stackFrame: IStackFrame, topStackFrameRange: IRange | undefined, isFocusedSession: boolean): IModelDeltaDecoration[] {
export function createDecorationsForStackFrame(stackFrame: IStackFrame, isFocusedSession: boolean): IModelDeltaDecoration[] {
// only show decorations for the currently focused thread.
const result: IModelDeltaDecoration[] = [];
const columnUntilEOLRange = new Range(stackFrame.range.startLineNumber, stackFrame.range.startColumn, stackFrame.range.startLineNumber, Constants.MAX_SAFE_SMALL_INTEGER);
@ -75,13 +75,10 @@ export function createDecorationsForStackFrame(stackFrame: IStackFrame, topStack
range: columnUntilEOLRange
});
if (topStackFrameRange && topStackFrameRange.startLineNumber === stackFrame.range.startLineNumber && topStackFrameRange.startColumn !== stackFrame.range.startColumn) {
result.push({
options: TOP_STACK_FRAME_INLINE_DECORATION,
range: columnUntilEOLRange
});
}
topStackFrameRange = columnUntilEOLRange;
result.push({
options: TOP_STACK_FRAME_INLINE_DECORATION,
range: columnUntilEOLRange
});
} else {
if (isFocusedSession) {
result.push({
@ -102,7 +99,6 @@ export function createDecorationsForStackFrame(stackFrame: IStackFrame, topStack
export class CallStackEditorContribution implements IEditorContribution {
private toDispose: IDisposable[] = [];
private decorationIds: string[] = [];
private topStackFrameRange: Range | undefined;
constructor(
private readonly editor: ICodeEditor,
@ -139,7 +135,7 @@ export class CallStackEditorContribution implements IEditorContribution {
stackFrames.forEach(candidateStackFrame => {
if (candidateStackFrame && this.uriIdentityService.extUri.isEqual(candidateStackFrame.source.uri, this.editor.getModel()?.uri)) {
decorations.push(...createDecorationsForStackFrame(candidateStackFrame, this.topStackFrameRange, isSessionFocused));
decorations.push(...createDecorationsForStackFrame(candidateStackFrame, isSessionFocused));
}
});
}

View file

@ -311,15 +311,15 @@ suite('Debug - CallStack', () => {
const session = createMockSession(model);
model.addSession(session);
const { firstStackFrame, secondStackFrame } = createTwoStackFrames(session);
let decorations = createDecorationsForStackFrame(firstStackFrame, firstStackFrame.range, true);
assert.strictEqual(decorations.length, 2);
let decorations = createDecorationsForStackFrame(firstStackFrame, true);
assert.strictEqual(decorations.length, 3);
assert.deepStrictEqual(decorations[0].range, new Range(1, 2, 1, 1));
assert.strictEqual(decorations[0].options.glyphMarginClassName, ThemeIcon.asClassName(debugStackframe));
assert.deepStrictEqual(decorations[1].range, new Range(1, Constants.MAX_SAFE_SMALL_INTEGER, 1, 1));
assert.strictEqual(decorations[1].options.className, 'debug-top-stack-frame-line');
assert.strictEqual(decorations[1].options.isWholeLine, true);
decorations = createDecorationsForStackFrame(secondStackFrame, firstStackFrame.range, true);
decorations = createDecorationsForStackFrame(secondStackFrame, true);
assert.strictEqual(decorations.length, 2);
assert.deepStrictEqual(decorations[0].range, new Range(1, 2, 1, 1));
assert.strictEqual(decorations[0].options.glyphMarginClassName, ThemeIcon.asClassName(debugStackframeFocused));
@ -327,7 +327,7 @@ suite('Debug - CallStack', () => {
assert.strictEqual(decorations[1].options.className, 'debug-focused-stack-frame-line');
assert.strictEqual(decorations[1].options.isWholeLine, true);
decorations = createDecorationsForStackFrame(firstStackFrame, new Range(1, 5, 1, 6), true);
decorations = createDecorationsForStackFrame(firstStackFrame, true);
assert.strictEqual(decorations.length, 3);
assert.deepStrictEqual(decorations[0].range, new Range(1, 2, 1, 1));
assert.strictEqual(decorations[0].options.glyphMarginClassName, ThemeIcon.asClassName(debugStackframe));