Skip to content

Commit

Permalink
Clicking the wrong RBL button should be a no-op
Browse files Browse the repository at this point in the history
Fix #6868
  • Loading branch information
roblourens committed Aug 11, 2021
1 parent e0dc6dd commit 88e9742
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
8 changes: 2 additions & 6 deletions src/client/debugger/jupyter/debuggingManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,15 @@ export class DebuggingManager implements IExtensionSingleActivationService, IDeb

this.commandManager.registerCommand(DSCommands.RunByLineContinue, (cell: NotebookCell) => {
const adapter = this.notebookToDebugAdapter.get(cell.notebook);
if (adapter) {
if (adapter && adapter.debugCellUri?.toString() === cell.document.uri.toString()) {
adapter.runByLineContinue();
} else {
void this.appShell.showErrorMessage(DataScience.noNotebookToDebug());
}
}),

this.commandManager.registerCommand(DSCommands.RunByLineStop, (cell: NotebookCell) => {
const adapter = this.notebookToDebugAdapter.get(cell.notebook);
if (adapter) {
if (adapter && adapter.debugCellUri?.toString() === cell.document.uri.toString()) {
adapter.disconnect();
} else {
void this.appShell.showErrorMessage(DataScience.noNotebookToDebug());
}
}),

Expand Down
16 changes: 13 additions & 3 deletions src/client/debugger/jupyter/kernelDebugAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
notebooks,
NotebookCellExecutionStateChangeEvent,
NotebookCellExecutionState,
DebugConfiguration
DebugConfiguration,
Uri
} from 'vscode';
import { DebugProtocol } from 'vscode-debugprotocol';
import { randomBytes } from 'crypto';
Expand Down Expand Up @@ -107,7 +108,11 @@ export interface IKernelDebugAdapterConfig extends DebugConfiguration {

function assertIsDebugConfig(thing: unknown): asserts thing is IKernelDebugAdapterConfig {
const config = thing as IKernelDebugAdapterConfig;
if (typeof config.__mode === 'undefined') {
if (
typeof config.__mode === 'undefined' ||
((config.__mode === KernelDebugMode.Cell || config.__mode === KernelDebugMode.RunByLine) &&
typeof config.__cellIndex === 'undefined')
) {
throw new Error('Invalid launch configuration');
}
}
Expand All @@ -123,6 +128,7 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter, ID
private threadId: number = 1;
private readonly disposables: IDisposable[] = [];
onDidSendMessage: Event<DebugProtocolMessage> = this.sendMessage.event;
public readonly debugCellUri: Uri | undefined;

constructor(
private session: DebugSession,
Expand All @@ -136,6 +142,10 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter, ID
assertIsDebugConfig(configuration);
this.configuration = configuration;

if (configuration.__mode === KernelDebugMode.Cell || configuration.__mode === KernelDebugMode.RunByLine) {
this.debugCellUri = notebookDocument.cellAt(configuration.__cellIndex!)?.document.uri;
}

const iopubHandler = (msg: KernelMessage.IIOPubMessage) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const content = msg.content as any;
Expand Down Expand Up @@ -458,7 +468,7 @@ export class KernelDebugAdapter implements DebugAdapter, IKernelDebugAdapter, ID
});

// put breakpoint at the beginning of the cell
const cellIndex = Number(this.session.configuration.__cellIndex);
const cellIndex = Number(this.configuration.__cellIndex);
const cell = this.notebookDocument.cellAt(cellIndex);

await this.dumpCell(cell.document.uri.toString());
Expand Down

0 comments on commit 88e9742

Please sign in to comment.