diff --git a/news/2 Fixes/4140.md b/news/2 Fixes/4140.md new file mode 100644 index 000000000000..cc07247c8cd7 --- /dev/null +++ b/news/2 Fixes/4140.md @@ -0,0 +1 @@ +Have the new export commands use our directory change code \ No newline at end of file diff --git a/src/client/datascience/historycommandlistener.ts b/src/client/datascience/historycommandlistener.ts index 2c354256ca48..f8f2d5e911d2 100644 --- a/src/client/datascience/historycommandlistener.ts +++ b/src/client/datascience/historycommandlistener.ts @@ -134,7 +134,13 @@ export class HistoryCommandListener implements IDataScienceCommandListener { await this.waitForStatus(async () => { if (uri) { - const notebook = await this.jupyterExporter.translateToNotebook(cells); + let directoryChange; + const settings = this.configuration.getSettings(); + if (settings.datascience.changeDirOnImportExport) { + directoryChange = uri.fsPath; + } + + const notebook = await this.jupyterExporter.translateToNotebook(cells, directoryChange); await this.fileSystem.writeFile(uri.fsPath, JSON.stringify(notebook)); } }, localize.DataScience.exportingFormat(), file); @@ -218,7 +224,12 @@ export class HistoryCommandListener implements IDataScienceCommandListener { }))); // Then save them to the file - const notebook = await this.jupyterExporter.translateToNotebook(cells); + let directoryChange; + if (settings.datascience.changeDirOnImportExport) { + directoryChange = file; + } + + const notebook = await this.jupyterExporter.translateToNotebook(cells, directoryChange); await this.fileSystem.writeFile(file, JSON.stringify(notebook)); } finally {