Skip to content

Commit 140771b

Browse files
committed
co-authored from @amunger via #24451
1 parent 79a1478 commit 140771b

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/client/repl/nativeRepl.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export class NativeRepl implements Disposable {
153153
/**
154154
* Function that opens interactive repl, selects kernel, and send/execute code to the native repl.
155155
*/
156-
public async sendToNativeRepl(code?: string): Promise<void> {
156+
public async sendToNativeRepl(code?: string | undefined, preserveFocus: boolean = true): Promise<void> {
157157
const mementoValue = (await this.context.globalState.get(NATIVE_REPL_URI_MEMENTO)) as string | undefined;
158158
let mementoUri = mementoValue ? Uri.parse(mementoValue) : undefined;
159159
const openNotebookDocuments = workspace.notebookDocuments.map((doc) => doc.uri);
@@ -177,7 +177,12 @@ export class NativeRepl implements Disposable {
177177
await this.cleanRepl();
178178
}
179179

180-
const notebookEditor = await openInteractiveREPL(this.replController, this.notebookDocument, mementoUri);
180+
const notebookEditor = await openInteractiveREPL(
181+
this.replController,
182+
this.notebookDocument,
183+
mementoUri,
184+
preserveFocus,
185+
);
181186

182187
this.notebookDocument = notebookEditor.notebook;
183188
await this.context.globalState.update(NATIVE_REPL_URI_MEMENTO, this.notebookDocument.uri.toString());

src/client/repl/replCommandHandler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export async function openInteractiveREPL(
2222
notebookController: NotebookController,
2323
notebookDocument: NotebookDocument | undefined,
2424
mementoValue: Uri | undefined,
25+
preserveFocus: boolean = true,
2526
): Promise<NotebookEditor> {
2627
let viewColumn = ViewColumn.Beside;
2728
if (mementoValue) {
@@ -40,7 +41,7 @@ export async function openInteractiveREPL(
4041
const editor = window.showNotebookDocument(notebookDocument!, {
4142
viewColumn,
4243
asRepl: 'Python REPL',
43-
preserveFocus: true,
44+
preserveFocus,
4445
});
4546
await commands.executeCommand('notebook.selectKernel', {
4647
editor,

src/client/repl/replCommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export async function registerStartNativeReplCommand(
3434
if (interpreter) {
3535
if (interpreter) {
3636
const nativeRepl = await getNativeRepl(interpreter, disposables, context);
37-
await nativeRepl.sendToNativeRepl();
37+
await nativeRepl.sendToNativeRepl(undefined, false);
3838
}
3939
}
4040
}),

0 commit comments

Comments
 (0)