Skip to content

Commit 7ccf01e

Browse files
authored
Correctly track native REPL state (#23997)
Resolves: #23996
1 parent 61bc2d5 commit 7ccf01e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/client/repl/nativeRepl.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { createReplController } from './replController';
2020
import { EventName } from '../telemetry/constants';
2121
import { sendTelemetryEvent } from '../telemetry';
2222

23+
let nativeRepl: NativeRepl | undefined; // In multi REPL scenario, hashmap of URI to Repl.
2324
export class NativeRepl implements Disposable {
2425
// Adding ! since it will get initialized in create method, not the constructor.
2526
private pythonServer!: PythonServer;
@@ -34,6 +35,8 @@ export class NativeRepl implements Disposable {
3435

3536
private notebookDocument: NotebookDocument | undefined;
3637

38+
public newReplSession: boolean | undefined = true;
39+
3740
// TODO: In the future, could also have attribute of URI for file specific REPL.
3841
private constructor() {
3942
this.watchNotebookClosed();
@@ -63,6 +66,7 @@ export class NativeRepl implements Disposable {
6366
workspace.onDidCloseNotebookDocument((nb) => {
6467
if (this.notebookDocument && nb.uri.toString() === this.notebookDocument.uri.toString()) {
6568
this.notebookDocument = undefined;
69+
this.newReplSession = true;
6670
}
6771
}),
6872
);
@@ -152,18 +156,19 @@ export class NativeRepl implements Disposable {
152156
}
153157
}
154158

155-
let nativeRepl: NativeRepl | undefined; // In multi REPL scenario, hashmap of URI to Repl.
156-
157159
/**
158160
* Get Singleton Native REPL Instance
159161
* @param interpreter
160162
* @returns Native REPL instance
161163
*/
162164
export async function getNativeRepl(interpreter: PythonEnvironment, disposables: Disposable[]): Promise<NativeRepl> {
163165
if (!nativeRepl) {
164-
sendTelemetryEvent(EventName.REPL, undefined, { replType: 'Native' });
165166
nativeRepl = await NativeRepl.create(interpreter);
166167
disposables.push(nativeRepl);
167168
}
169+
if (nativeRepl && nativeRepl.newReplSession) {
170+
sendTelemetryEvent(EventName.REPL, undefined, { replType: 'Native' });
171+
nativeRepl.newReplSession = false;
172+
}
168173
return nativeRepl;
169174
}

0 commit comments

Comments
 (0)