@@ -20,6 +20,7 @@ import { createReplController } from './replController';
20
20
import { EventName } from '../telemetry/constants' ;
21
21
import { sendTelemetryEvent } from '../telemetry' ;
22
22
23
+ let nativeRepl : NativeRepl | undefined ; // In multi REPL scenario, hashmap of URI to Repl.
23
24
export class NativeRepl implements Disposable {
24
25
// Adding ! since it will get initialized in create method, not the constructor.
25
26
private pythonServer ! : PythonServer ;
@@ -34,6 +35,8 @@ export class NativeRepl implements Disposable {
34
35
35
36
private notebookDocument : NotebookDocument | undefined ;
36
37
38
+ public newReplSession : boolean | undefined = true ;
39
+
37
40
// TODO: In the future, could also have attribute of URI for file specific REPL.
38
41
private constructor ( ) {
39
42
this . watchNotebookClosed ( ) ;
@@ -63,6 +66,7 @@ export class NativeRepl implements Disposable {
63
66
workspace . onDidCloseNotebookDocument ( ( nb ) => {
64
67
if ( this . notebookDocument && nb . uri . toString ( ) === this . notebookDocument . uri . toString ( ) ) {
65
68
this . notebookDocument = undefined ;
69
+ this . newReplSession = true ;
66
70
}
67
71
} ) ,
68
72
) ;
@@ -152,18 +156,19 @@ export class NativeRepl implements Disposable {
152
156
}
153
157
}
154
158
155
- let nativeRepl : NativeRepl | undefined ; // In multi REPL scenario, hashmap of URI to Repl.
156
-
157
159
/**
158
160
* Get Singleton Native REPL Instance
159
161
* @param interpreter
160
162
* @returns Native REPL instance
161
163
*/
162
164
export async function getNativeRepl ( interpreter : PythonEnvironment , disposables : Disposable [ ] ) : Promise < NativeRepl > {
163
165
if ( ! nativeRepl ) {
164
- sendTelemetryEvent ( EventName . REPL , undefined , { replType : 'Native' } ) ;
165
166
nativeRepl = await NativeRepl . create ( interpreter ) ;
166
167
disposables . push ( nativeRepl ) ;
167
168
}
169
+ if ( nativeRepl && nativeRepl . newReplSession ) {
170
+ sendTelemetryEvent ( EventName . REPL , undefined , { replType : 'Native' } ) ;
171
+ nativeRepl . newReplSession = false ;
172
+ }
168
173
return nativeRepl ;
169
174
}
0 commit comments