From 998fbac7099a94de053f82ac189e1be586edf6f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Zlatniczki?= Date: Fri, 23 Sep 2022 00:08:16 +0200 Subject: [PATCH] Fix for issue #11396 * During notebook cell debugging, apply path normalization on the path of the dumped tmp file only if the kernel runs on a Windows machine. --- news/2 Fixes/11396.md | 2 ++ src/notebooks/debugger/kernelDebugAdapter.ts | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 news/2 Fixes/11396.md diff --git a/news/2 Fixes/11396.md b/news/2 Fixes/11396.md new file mode 100644 index 000000000000..04587746a648 --- /dev/null +++ b/news/2 Fixes/11396.md @@ -0,0 +1,2 @@ +Fixed a bug that introduced a cross-OS interworking issue, making the notebook cell debugger skip breakpoints when VSCode is run on Windows but the kernel is run on Unix +(thanks [Adam Zlatniczki](https://github.com/adam-zlatniczki)) diff --git a/src/notebooks/debugger/kernelDebugAdapter.ts b/src/notebooks/debugger/kernelDebugAdapter.ts index c6ee1bd5bda0..dfb17d3fe652 100644 --- a/src/notebooks/debugger/kernelDebugAdapter.ts +++ b/src/notebooks/debugger/kernelDebugAdapter.ts @@ -22,7 +22,18 @@ export class KernelDebugAdapter extends KernelDebugAdapterBase { const response = await this.session.customRequest('dumpCell', { code: cell.document.getText().replace(/\r\n/g, '\n') }); - const norm = path.normalize((response as IDumpCellResponse).sourcePath); + + // Based on the response, check if the kernel runs on a Unix or Windows machine. + // If it runs on Windows, then path normalization might be necessary + // (see https://github.com/ipython/ipykernel/issues/995). + const dumpFilePathOnKernelSide = (response as IDumpCellResponse).sourcePath; + var norm = ''; + if (dumpFilePathOnKernelSide.match('[A-Za-z]:.*')) { + norm = path.normalize(dumpFilePathOnKernelSide); + } else { + norm = dumpFilePathOnKernelSide; + } + this.fileToCell.set(norm, cell.document.uri); this.cellToFile.set(cell.document.uri.toString(), norm); } catch (err) {