diff --git a/src/interactive-window/debugger/jupyter/kernelDebugAdapter.ts b/src/interactive-window/debugger/jupyter/kernelDebugAdapter.ts index a1c8065d07a..f7473d6f067 100644 --- a/src/interactive-window/debugger/jupyter/kernelDebugAdapter.ts +++ b/src/interactive-window/debugger/jupyter/kernelDebugAdapter.ts @@ -9,7 +9,7 @@ import { DebugAdapterTracker, DebugSession, NotebookDocument, Uri } from 'vscode import { DebugProtocol } from 'vscode-debugprotocol'; import { IKernel, IKernelConnectionSession } from '../../../kernels/types'; import { IPlatformService } from '../../../platform/common/platform/types'; -import { IDumpCellResponse, IDebugLocationTrackerFactory } from '../../../notebooks/debugger/debuggingTypes'; +import { IDebugLocationTrackerFactory } from '../../../notebooks/debugger/debuggingTypes'; import { traceError, traceInfo, traceInfoIfCI } from '../../../platform/logging'; import { getInteractiveCellMetadata } from '../../../interactive-window/helpers'; import { KernelDebugAdapterBase } from '../../../notebooks/debugger/kernelDebugAdapterBase'; @@ -90,7 +90,8 @@ export class KernelDebugAdapter extends KernelDebugAdapterBase { const response = await this.session.customRequest('dumpCell', { code }); // We know jupyter will strip out leading white spaces, hence take that into account. - const norm = path.normalize((response as IDumpCellResponse).sourcePath); + const norm = KernelDebugAdapterBase.normalizeFsAware(response.sourcePath); + traceInfoIfCI(`KernelDebugAdapter::dumpCell ${response.sourcePath} -> ${norm}`); this.fileToCell.set(norm, Uri.parse(metadata.interactive.uristring)); // If this cell doesn't have a cell marker, then diff --git a/src/notebooks/debugger/kernelDebugAdapter.ts b/src/notebooks/debugger/kernelDebugAdapter.ts index c6ee1bd5bda..3e42ba62e47 100644 --- a/src/notebooks/debugger/kernelDebugAdapter.ts +++ b/src/notebooks/debugger/kernelDebugAdapter.ts @@ -3,11 +3,10 @@ 'use strict'; -import * as path from '../../platform/vscode-path/path'; -import { IDumpCellResponse } from './debuggingTypes'; -import { traceError } from '../../platform/logging'; +import { traceError, traceInfoIfCI } from '../../platform/logging'; import { KernelDebugAdapterBase } from './kernelDebugAdapterBase'; import { DebugProtocol } from 'vscode-debugprotocol'; +import { IDumpCellResponse } from './debuggingTypes'; /** * Concrete implementation of the KernelDebugAdapterBase class that will dump cells @@ -19,10 +18,11 @@ export class KernelDebugAdapter extends KernelDebugAdapterBase { protected override async dumpCell(index: number): Promise { const cell = this.notebookDocument.cellAt(index); try { - const response = await this.session.customRequest('dumpCell', { + const response = (await this.session.customRequest('dumpCell', { code: cell.document.getText().replace(/\r\n/g, '\n') - }); - const norm = path.normalize((response as IDumpCellResponse).sourcePath); + })) as IDumpCellResponse; + const norm = KernelDebugAdapterBase.normalizeFsAware(response.sourcePath); + traceInfoIfCI(`KernelDebugAdapter::dumpCell ${response.sourcePath} -> ${norm}`); this.fileToCell.set(norm, cell.document.uri); this.cellToFile.set(cell.document.uri.toString(), norm); } catch (err) { diff --git a/src/notebooks/debugger/kernelDebugAdapterBase.ts b/src/notebooks/debugger/kernelDebugAdapterBase.ts index 5d2dba511a9..2a0943afe3e 100644 --- a/src/notebooks/debugger/kernelDebugAdapterBase.ts +++ b/src/notebooks/debugger/kernelDebugAdapterBase.ts @@ -264,6 +264,23 @@ export abstract class KernelDebugAdapterBase implements DebugAdapter, IKernelDeb }); } + static normalizeFsAware(sourcePath: string) { + // If the kernel runs on Windows, then do windows-style path normalization + // (see https://github.com/ipython/ipykernel/issues/995). + let norm = ''; + if (sourcePath.match(/^[A-Za-z]:/)) { + norm = path.win32.normalize(sourcePath); + } else { + traceInfoIfCI( + `KernelDebugAdapter::normalizeFsAware ${sourcePath} would normalize to ${path.posix.normalize( + sourcePath + )}` + ); + norm = path.posix.normalize(sourcePath); + } + return norm; + } + private lookupCellByLongName(sourcePath: string) { if (!this.platformService.isWindows) { return undefined;