Skip to content

Commit

Permalink
Workaround for #11774 (#12181)
Browse files Browse the repository at this point in the history
This issue causes step-in with justMyCode enabled to stop multiple times on the same line.
  • Loading branch information
roblourens authored Nov 27, 2022
1 parent 09d4d5e commit 1bf30dc
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/notebooks/debugger/controllers/runByLineController.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { NotebookCell } from 'vscode';
import { NotebookCell, Position } from 'vscode';
import { DebugProtocol } from 'vscode-debugprotocol';
import { INotebookKernelExecution } from '../../../kernels/types';
import { ICommandManager } from '../../../platform/common/application/types';
Expand All @@ -22,6 +22,7 @@ import { isJustMyCodeNotification } from './debugCellController';
*/
export class RunByLineController implements IDebuggingDelegate {
private lastPausedThreadId: number | undefined;
private lastPausePosition: Position | undefined;

constructor(
private readonly debugAdapter: IKernelDebugAdapter,
Expand Down Expand Up @@ -99,6 +100,14 @@ export class RunByLineController implements IDebuggingDelegate {

if (stResponse && stResponse.stackFrames[0]) {
const sf = stResponse.stackFrames[0];
const pausePos = new Position(sf.line, sf.column);
if (this.lastPausePosition?.isEqual(pausePos)) {
// This is a workaround for https://github.com/microsoft/debugpy/issues/1104
this.trace('intercept', 'working around duplicate stop event');
return true;
}

this.lastPausePosition = pausePos;
return !!sf.source && sf.source.path !== this.debugCell.document.uri.toString();
}

Expand Down

0 comments on commit 1bf30dc

Please sign in to comment.