MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / insertIntoInputEditor

Function insertIntoInputEditor

src/test/datascience/helpers.ts:79–104  ·  view source on GitHub ↗
(source: string, interactiveWindow?: InteractiveWindow)

Source from the content-addressed store, hash-verified

77
78// Add code to the input box
79export 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
106export async function setActiveInterpreter(
107 apiProvider: IPythonApiProvider,

Calls 5

mapMethod · 0.80
errorMethod · 0.65
executeCommandMethod · 0.65
editMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected