@@ -12,7 +12,7 @@ import { Kernel, saveAllFilesAndCloseAll } from './notebook.api.test';
12
12
export type INativeInteractiveWindow = { notebookUri : vscode . Uri ; inputUri : vscode . Uri ; notebookEditor : vscode . NotebookEditor } ;
13
13
14
14
async function createInteractiveWindow ( kernel : Kernel ) {
15
- const { notebookEditor } = ( await vscode . commands . executeCommand (
15
+ const { notebookEditor, inputUri } = ( await vscode . commands . executeCommand (
16
16
'interactive.open' ,
17
17
// Keep focus on the owning file if there is one
18
18
{ viewColumn : vscode . ViewColumn . Beside , preserveFocus : false } ,
@@ -21,7 +21,7 @@ async function createInteractiveWindow(kernel: Kernel) {
21
21
undefined
22
22
) ) as unknown as INativeInteractiveWindow ;
23
23
24
- return notebookEditor ;
24
+ return { notebookEditor, inputUri } ;
25
25
}
26
26
27
27
async function addCell ( code : string , notebook : vscode . NotebookDocument ) {
@@ -61,21 +61,26 @@ async function addCellAndRun(code: string, notebook: vscode.NotebookDocument, i:
61
61
await saveAllFilesAndCloseAll ( ) ;
62
62
} ) ;
63
63
64
- test ( 'Can open an interactive window' , async ( ) => {
64
+ test ( 'Can open an interactive window and execute from input box ' , async ( ) => {
65
65
assert . ok ( vscode . workspace . workspaceFolders ) ;
66
- const notebookEditor = await createInteractiveWindow ( defaultKernel ) ;
66
+ const { notebookEditor, inputUri } = await createInteractiveWindow ( defaultKernel ) ;
67
67
assert . ok ( notebookEditor ) ;
68
68
69
- // Try adding a cell and running it.
70
- await addCell ( 'print foo' , notebookEditor . notebook ) ;
69
+ const inputBox = vscode . window . visibleTextEditors . find (
70
+ ( e ) => e . document . uri . path === inputUri . path
71
+ ) ;
72
+ await inputBox ! . edit ( ( editBuilder ) => {
73
+ editBuilder . insert ( new vscode . Position ( 0 , 0 ) , 'print foo' ) ;
74
+ } ) ;
75
+ await vscode . commands . executeCommand ( 'interactive.execute' , notebookEditor . notebook . uri ) ;
71
76
72
77
assert . strictEqual ( notebookEditor . notebook . cellCount , 1 ) ;
73
78
assert . strictEqual ( notebookEditor . notebook . cellAt ( 0 ) . kind , vscode . NotebookCellKind . Code ) ;
74
79
} ) ;
75
80
76
81
test ( 'Interactive window scrolls after execute' , async ( ) => {
77
82
assert . ok ( vscode . workspace . workspaceFolders ) ;
78
- const notebookEditor = await createInteractiveWindow ( defaultKernel ) ;
83
+ const { notebookEditor } = await createInteractiveWindow ( defaultKernel ) ;
79
84
assert . ok ( notebookEditor ) ;
80
85
81
86
// Run and add a bunch of cells
@@ -90,13 +95,13 @@ async function addCellAndRun(code: string, notebook: vscode.NotebookDocument, i:
90
95
91
96
test ( 'Interactive window has the correct kernel' , async ( ) => {
92
97
assert . ok ( vscode . workspace . workspaceFolders ) ;
93
- const notebookEditor = await createInteractiveWindow ( defaultKernel ) ;
98
+ const { notebookEditor } = await createInteractiveWindow ( defaultKernel ) ;
94
99
assert . ok ( notebookEditor ) ;
95
100
96
101
await vscode . commands . executeCommand ( 'workbench.action.closeActiveEditor' ) ;
97
102
98
103
// Create a new interactive window with a different kernel
99
- const notebookEditor2 = await createInteractiveWindow ( secondKernel ) ;
104
+ const { notebookEditor : notebookEditor2 } = await createInteractiveWindow ( secondKernel ) ;
100
105
assert . ok ( notebookEditor2 ) ;
101
106
102
107
// Verify the kernel is the secondary one
0 commit comments