Skip to content

Commit 3190d6f

Browse files
Dev/ianhu/add directory change to new export commands (#4151)
* tests and hygiene * new entry * remove comment * add directory change * add news
1 parent 7ce203d commit 3190d6f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

news/2 Fixes/4140.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Have the new export commands use our directory change code

src/client/datascience/historycommandlistener.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,13 @@ export class HistoryCommandListener implements IDataScienceCommandListener {
134134

135135
await this.waitForStatus(async () => {
136136
if (uri) {
137-
const notebook = await this.jupyterExporter.translateToNotebook(cells);
137+
let directoryChange;
138+
const settings = this.configuration.getSettings();
139+
if (settings.datascience.changeDirOnImportExport) {
140+
directoryChange = uri.fsPath;
141+
}
142+
143+
const notebook = await this.jupyterExporter.translateToNotebook(cells, directoryChange);
138144
await this.fileSystem.writeFile(uri.fsPath, JSON.stringify(notebook));
139145
}
140146
}, localize.DataScience.exportingFormat(), file);
@@ -218,7 +224,12 @@ export class HistoryCommandListener implements IDataScienceCommandListener {
218224
})));
219225

220226
// Then save them to the file
221-
const notebook = await this.jupyterExporter.translateToNotebook(cells);
227+
let directoryChange;
228+
if (settings.datascience.changeDirOnImportExport) {
229+
directoryChange = file;
230+
}
231+
232+
const notebook = await this.jupyterExporter.translateToNotebook(cells, directoryChange);
222233
await this.fileSystem.writeFile(file, JSON.stringify(notebook));
223234

224235
} finally {

0 commit comments

Comments
 (0)