File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff 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/**
Original file line number Diff line number Diff 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,
You can’t perform that action at this time.
0 commit comments