Skip to content

Commit

Permalink
fix: workaround for microsoft/vscode-mock-debug#85
Browse files Browse the repository at this point in the history
Signed-off-by: Akos Kitta <[email protected]>
  • Loading branch information
Akos Kitta committed Jan 18, 2023
1 parent 4e5057c commit 804c93f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/debug/src/browser/model/debug-stack-frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ export class DebugStackFrame extends DebugStackFrameData implements TreeElement
}
const { line, column, endLine, endColumn } = this.raw;
const selection: RecursivePartial<Range> = {
start: Position.create(line - 1, column - 1)
start: Position.create(this.coerceNonNegative(line - 1), this.coerceNonNegative(column - 1))
};
if (typeof endLine === 'number') {
selection.end = {
line: endLine - 1,
character: typeof endColumn === 'number' ? endColumn - 1 : undefined
line: this.coerceNonNegative(endLine - 1),
character: typeof endColumn === 'number' ? this.coerceNonNegative(endColumn - 1) : undefined
};
}
this.source.open({
Expand All @@ -86,6 +86,15 @@ export class DebugStackFrame extends DebugStackFrameData implements TreeElement
});
}

/**
* Debugger can send `column: 0` value despite of initializing the debug session with `columnsStartAt1: true`.
* This method can be used to ensure that neither `column` nor `column` are negative numbers.
* See https://github.com/microsoft/vscode-mock-debug/issues/85.
*/
protected coerceNonNegative(value: number): number {
return value < 0 ? 0 : value;
}

protected scopes: Promise<DebugScope[]> | undefined;
getScopes(): Promise<DebugScope[]> {
return this.scopes || (this.scopes = this.doGetScopes());
Expand Down

0 comments on commit 804c93f

Please sign in to comment.