Skip to content

Commit a1af315

Browse files
committed
pass through param to set focus on the REPL editor
1 parent a2b007c commit a1af315

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

src/client/repl/nativeRepl.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,12 @@ export class NativeRepl implements Disposable {
145145
/**
146146
* Function that opens interactive repl, selects kernel, and send/execute code to the native repl.
147147
*/
148-
public async sendToNativeRepl(code?: string): Promise<void> {
149-
const notebookEditor = await openInteractiveREPL(this.replController, this.notebookDocument);
148+
public async sendToNativeRepl(code?: string | undefined, preserveFocus: boolean = true): Promise<void> {
149+
const notebookEditor = await openInteractiveREPL(this.replController, this.notebookDocument, preserveFocus);
150150
this.notebookDocument = notebookEditor.notebook;
151151

152152
if (this.notebookDocument) {
153-
this.replController.updateNotebookAffinity(this.notebookDocument, NotebookControllerAffinity.Default);
153+
this.replController.updateNotebookAffinity(this.notebookDocument, NotebookControllerAffinity.Preferred);
154154
await selectNotebookKernel(notebookEditor, this.replController.id, PVSC_EXTENSION_ID);
155155
if (code) {
156156
await executeNotebookCell(notebookEditor, code);

src/client/repl/replCommandHandler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { PVSC_EXTENSION_ID } from '../common/constants';
2020
export async function openInteractiveREPL(
2121
notebookController: NotebookController,
2222
notebookDocument: NotebookDocument | undefined,
23+
preserveFocus: boolean = true,
2324
): Promise<NotebookEditor> {
2425
let viewColumn = ViewColumn.Beside;
2526

@@ -34,7 +35,7 @@ export async function openInteractiveREPL(
3435
const editor = window.showNotebookDocument(notebookDocument!, {
3536
viewColumn,
3637
asRepl: 'Python REPL',
37-
preserveFocus: true,
38+
preserveFocus,
3839
});
3940
await commands.executeCommand('notebook.selectKernel', {
4041
editor,

src/client/repl/replCommands.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ export async function registerStartNativeReplCommand(
3131
sendTelemetryEvent(EventName.REPL, undefined, { replType: 'Native' });
3232
const interpreter = await getActiveInterpreter(uri, interpreterService);
3333
if (interpreter) {
34-
if (interpreter) {
35-
const nativeRepl = await getNativeRepl(interpreter, disposables);
36-
await nativeRepl.sendToNativeRepl();
37-
}
34+
const nativeRepl = await getNativeRepl(interpreter, disposables);
35+
await nativeRepl.sendToNativeRepl(undefined, false);
3836
}
3937
}),
4038
);

0 commit comments

Comments
 (0)