(source: string, interactiveWindow?: InteractiveWindow)
| 77 | |
| 78 | // Add code to the input box |
| 79 | export async function insertIntoInputEditor(source: string, interactiveWindow?: InteractiveWindow) { |
| 80 | let inputBox: vscode.TextEditor | undefined; |
| 81 | if (interactiveWindow) { |
| 82 | inputBox = vscode.window.visibleTextEditors.find( |
| 83 | (e) => e.document.uri.path === interactiveWindow.inputUri.path |
| 84 | ); |
| 85 | if (!inputBox) { |
| 86 | logger.error( |
| 87 | `couldn't find input box ${interactiveWindow.inputUri.path} in visible text editors ${JSON.stringify( |
| 88 | vscode.window.visibleTextEditors.map((e) => e.document.uri.path) |
| 89 | )}` |
| 90 | ); |
| 91 | } |
| 92 | } |
| 93 | if (!inputBox) { |
| 94 | await vscode.commands.executeCommand('interactive.input.focus'); |
| 95 | inputBox = vscode.window.activeTextEditor; |
| 96 | } |
| 97 | |
| 98 | assert(inputBox, 'No active text editor for IW input'); |
| 99 | |
| 100 | await inputBox!.edit((editBuilder) => { |
| 101 | editBuilder.insert(new vscode.Position(0, 0), source); |
| 102 | }); |
| 103 | return vscode.window.activeTextEditor; |
| 104 | } |
| 105 | |
| 106 | export async function setActiveInterpreter( |
| 107 | apiProvider: IPythonApiProvider, |
no test coverage detected