From a1af3156426eac13a4d31fa76cd97f067b90942f Mon Sep 17 00:00:00 2001 From: amunger Date: Fri, 15 Nov 2024 12:59:21 -0800 Subject: [PATCH] pass through param to set focus on the REPL editor --- src/client/repl/nativeRepl.ts | 6 +++--- src/client/repl/replCommandHandler.ts | 3 ++- src/client/repl/replCommands.ts | 6 ++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/client/repl/nativeRepl.ts b/src/client/repl/nativeRepl.ts index 8304a27db6ea..1afc9a67a2df 100644 --- a/src/client/repl/nativeRepl.ts +++ b/src/client/repl/nativeRepl.ts @@ -145,12 +145,12 @@ export class NativeRepl implements Disposable { /** * Function that opens interactive repl, selects kernel, and send/execute code to the native repl. */ - public async sendToNativeRepl(code?: string): Promise { - const notebookEditor = await openInteractiveREPL(this.replController, this.notebookDocument); + public async sendToNativeRepl(code?: string | undefined, preserveFocus: boolean = true): Promise { + const notebookEditor = await openInteractiveREPL(this.replController, this.notebookDocument, preserveFocus); this.notebookDocument = notebookEditor.notebook; if (this.notebookDocument) { - this.replController.updateNotebookAffinity(this.notebookDocument, NotebookControllerAffinity.Default); + this.replController.updateNotebookAffinity(this.notebookDocument, NotebookControllerAffinity.Preferred); await selectNotebookKernel(notebookEditor, this.replController.id, PVSC_EXTENSION_ID); if (code) { await executeNotebookCell(notebookEditor, code); diff --git a/src/client/repl/replCommandHandler.ts b/src/client/repl/replCommandHandler.ts index 13e7607b5cc8..23959625a5d8 100644 --- a/src/client/repl/replCommandHandler.ts +++ b/src/client/repl/replCommandHandler.ts @@ -20,6 +20,7 @@ import { PVSC_EXTENSION_ID } from '../common/constants'; export async function openInteractiveREPL( notebookController: NotebookController, notebookDocument: NotebookDocument | undefined, + preserveFocus: boolean = true, ): Promise { let viewColumn = ViewColumn.Beside; @@ -34,7 +35,7 @@ export async function openInteractiveREPL( const editor = window.showNotebookDocument(notebookDocument!, { viewColumn, asRepl: 'Python REPL', - preserveFocus: true, + preserveFocus, }); await commands.executeCommand('notebook.selectKernel', { editor, diff --git a/src/client/repl/replCommands.ts b/src/client/repl/replCommands.ts index eb2eb49aea76..993a0cc91b19 100644 --- a/src/client/repl/replCommands.ts +++ b/src/client/repl/replCommands.ts @@ -31,10 +31,8 @@ export async function registerStartNativeReplCommand( sendTelemetryEvent(EventName.REPL, undefined, { replType: 'Native' }); const interpreter = await getActiveInterpreter(uri, interpreterService); if (interpreter) { - if (interpreter) { - const nativeRepl = await getNativeRepl(interpreter, disposables); - await nativeRepl.sendToNativeRepl(); - } + const nativeRepl = await getNativeRepl(interpreter, disposables); + await nativeRepl.sendToNativeRepl(undefined, false); } }), );