Skip to content

Commit fc966f5

Browse files
committed
more refactoring to make my life easier
1 parent 44bd14d commit fc966f5

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/client/repl/nativeRepl.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,11 @@ export class NativeRepl implements Disposable {
170170
// e.g. creation of untitled notebook without Python extension knowing.
171171
if (getTabNameForUri(replTabBeforeReload) !== 'Python REPL') {
172172
mementoUri = undefined;
173-
await this.context.globalState.update(NATIVE_REPL_URI_MEMENTO, undefined);
174-
this.notebookDocument = undefined;
173+
await this.cleanRepl();
175174
}
176175
}
177176
} else {
178-
mementoUri = undefined;
179-
await this.context.globalState.update(NATIVE_REPL_URI_MEMENTO, undefined);
180-
this.notebookDocument = undefined;
177+
await this.cleanRepl();
181178
}
182179

183180
const notebookEditor = await openInteractiveREPL(this.replController, this.notebookDocument, mementoUri);
@@ -193,6 +190,15 @@ export class NativeRepl implements Disposable {
193190
}
194191
}
195192
}
193+
194+
/**
195+
* Properly clean up notebook document stored inside Native REPL.
196+
* Also remove the Native REPL URI from memento to prepare for brand new REPL creation.
197+
*/
198+
private async cleanRepl(): Promise<void> {
199+
this.notebookDocument = undefined;
200+
await this.context.globalState.update(NATIVE_REPL_URI_MEMENTO, undefined);
201+
}
196202
}
197203

198204
/**

src/client/repl/replUtils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export function getExistingReplViewColumn(notebookDocument: NotebookDocument): V
9999
}
100100
return undefined;
101101
}
102+
102103
/**
103104
* Function that will return tab name for before reloading VS Code
104105
* This is so we can make sure tab name is still 'Python REPL' after reloading VS Code,

0 commit comments

Comments
 (0)