From 3190d6f2fb310cd92a6709bc0ae66689c76cd85f Mon Sep 17 00:00:00 2001 From: Ian Huff Date: Mon, 28 Jan 2019 09:14:18 -0800 Subject: [PATCH] Dev/ianhu/add directory change to new export commands (#4151) * tests and hygiene * new entry * remove comment * add directory change * add news --- news/2 Fixes/4140.md | 1 + src/client/datascience/historycommandlistener.ts | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 news/2 Fixes/4140.md 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 {