ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / vscode-api-tests / src / singlefolder-tests / notebook.kernel.test.ts 470 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
import * as assert from 'assert' ;
import 'mocha' ;
import { TextDecoder } from 'util' ;
import * as vscode from 'vscode' ;
import { asPromise, assertNoRpc, closeAllEditors, createRandomFile, DeferredPromise, disposeAll, revertAllDirty, saveAllEditors } from '../utils' ;
async function createRandomNotebookFile ( ) {
return createRandomFile ( '' , undefined , '.vsctestnb'
uri
vscode workspace uri
event vscode Event e
e event
e
ms
resolve
resolve ms
controller vscode NotebookController
associatedNotebooks
id label viewType
controller vscode notebooks id viewType label
controller executeHandler
controller supportsExecutionOrder
controller supportedLanguages
controller e
e selected
associatedNotebooks e notebook uri
associatedNotebooks e notebook uri
cells vscode NotebookCell
cell cells
cell
cell vscode NotebookCell
task controller cell
task Date
task executionOrder
task
vscode NotebookCellOutputItem cell document cell document uri
task
kernel Kernel notebook vscode NotebookDocument
success vscode commands
extension
id kernel controller id
assert success
assert kernel associatedNotebooks notebook uri
apiTestSerializer vscode NotebookSerializer
_data _token
_content _token
dto vscode NotebookData
metadata testMetadata
cells
value
languageId
kind vscode NotebookCellKind Code
outputs
metadata testCellMetadata
executionSummary timing startTime endTime
value
languageId
kind vscode NotebookCellKind Code
outputs
vscode NotebookCellOutputItem
testOutputMetadata
testOutputItemMetadata
executionSummary executionOrder success
metadata testCellMetadata
dto
vscode env uiKind vscode UIKind Web suite skip suite
testDisposables vscode Disposable
suiteDisposables vscode Disposable
suiteDisposables
suiteDisposables length
suiteDisposables vscode workspace apiTestSerializer
defaultKernel Kernel
defaultKernel
testDisposables defaultKernel controller
testDisposables
testDisposables length
notebook
vscode window notebook
assert vscode window activeNotebookEditor
editor vscode window activeNotebookEditor
cell editor notebook
vscode workspace onDidChangeNotebookDocument event
vscode commands
event
assert cell outputs length
vscode workspace onDidChangeNotebookDocument event
vscode commands
event
assert cell outputs length
secondResource
secondDocument vscode workspace secondResource
vscode window secondDocument
vscode workspace onDidChangeNotebookDocument event
vscode commands start end notebook uri
event
assert cell outputs length
assert vscode window activeNotebookEditor notebook uri fsPath secondResource fsPath
notebook
vscode window notebook
firstCellExecuted
secondCellExecuted
def
testDisposables vscode workspace e
e cellChanges change
change cell index change executionSummary
firstCellExecuted
change cell index change executionSummary
secondCellExecuted
firstCellExecuted secondCellExecuted
def
vscode commands document notebook uri ranges start end start end
def p
notebook
vscode window notebook
assert vscode window activeNotebookEditor
editor vscode window activeNotebookEditor
cell editor notebook
vscode workspace onDidChangeNotebookDocument event
vscode commands notebook uri
event
assert cell outputs length
notebook
editor vscode window notebook
assert vscode window activeNotebookEditor editor
cell editor notebook
alternativeKernel
controller supportsExecutionOrder
override cell vscode NotebookCell
task controller cell
task
task
vscode NotebookCellOutputItem
task
testDisposables alternativeKernel controller
vscode workspace onDidChangeNotebookDocument event
defaultKernel notebook
vscode commands
event
assert cell outputs length
assert cell outputs items length
assert cell outputs items mime
assert cell outputs items data cell document
vscode workspace onDidChangeNotebookDocument event
alternativeKernel notebook
vscode commands
event
assert cell outputs length
assert cell outputs items length
assert cell outputs items mime
assert cell outputs items data
called
verifyOutputSyncKernel
override cells vscode NotebookCell
cell cells
task controller cell
task
task
vscode NotebookCellOutputItem
assert cell notebook outputs length
assert cell notebook outputs items data
task
called
notebook
vscode window notebook
verifyOutputSyncKernel notebook
vscode commands
assert called
verifyOutputSyncKernel controller
notebook
editor vscode window notebook
cell editor notebook
assert cell executionSummary success
assert cell executionSummary executionOrder
vscode commands
assert cell outputs length
assert cell executionSummary
assert cell executionSummary success
assert cell executionSummary executionOrder
document
cell document
assert cell executionSummary success
assert cell executionSummary timing startTime
assert cell executionSummary timing endTime
document
cell document
executionWasCancelled
cancelledKernel
override cells vscode NotebookCell
cell cells
exe controller cell
exe token executionWasCancelled
testDisposables cancelledKernel controller
vscode window document
cancelledKernel document
vscode commands
edit
edit cell notebook uri vscode NotebookEdit cell index cell index
vscode workspace edit
assert executionWasCancelled
notebook
editor vscode window notebook
cell0 editor notebook
notebookEdit vscode NotebookCellKind Code
edit
edit notebook uri notebookEdit
vscode workspace edit
cell1 editor notebook
nextCellKernel
override cell vscode NotebookCell
task controller cell
task
task
vscode NotebookCellOutputItem
cell1
task
vscode NotebookCellOutputItem
cell1
task
testDisposables nextCellKernel controller
vscode workspace onDidChangeNotebookDocument event
nextCellKernel notebook
vscode commands
event
assert cell0 outputs length
assert cell1 outputs length
assert cell1 outputs items length
assert cell1 outputs items data
notebook
editor vscode window notebook
cell0 editor notebook
notebookEdit vscode NotebookCellKind Code
edit
edit notebook uri notebookEdit
vscode workspace edit
cell1 editor notebook
nextCellKernel
override cell vscode NotebookCell
task controller cell
task
task
vscode NotebookCellOutputItem
cell1
task
vscode NotebookCellOutputItem
cell1
task
testDisposables nextCellKernel controller
vscode workspace onDidChangeNotebookDocument event
nextCellKernel notebook
vscode commands
event
assert cell0 outputs length
assert cell1 outputs length
assert cell1 outputs items length
assert cell1 outputs items data
)
;
}
async
function
openRandomNotebookDocument
(
)
{
const
=
await
createRandomNotebookFile
(
)
;
return
.
.
openNotebookDocument
(
)
;
}
export
async
function
saveAllFilesAndCloseAll
(
)
{
await
saveAllEditors
(
)
;
await
closeAllEditors
(
)
;
}
async
function
withEvent < T >
(
:
.
<
T
>
,
callback
:
(
:
Promise
<
T
>
)
=>
Promise
<
void
>
)
{
const
=
asPromise < T >
(
)
;
await
callback
(
)
;
}
function
sleep
(
:
number
)
:
Promise
<
void
>
{
return
new
Promise
(
=>
{
setTimeout
(
,
)
;
}
)
;
}
export
class
Kernel
{
readonly
:
.
;
readonly
=
new
Set< string >
(
)
;
constructor
(
:
string
,
:
string
,
:
string
=
'notebookCoreTest'
)
{
this
.
=
.
.
createNotebookController
(
,
,
)
;
this
.
.
=
this
.
_execute
.
bind
(
this
)
;
this
.
.
=
true
;
this
.
.
=
[
'typescript'
,
'javascript'
]
;
this
.
.
onDidChangeSelectedNotebooks
(
=>
{
if
(
.
)
{
this
.
.
add
(
.
.
.
toString
(
)
)
;
}
else
{
this
.
.
delete
(
.
.
.
toString
(
)
)
;
}
}
)
;
}
protected
async
_execute
(
:
.
[
]
)
:
Promise
<
void
>
{
for
(
const
of
)
{
await
this
.
_runCell
(
)
;
}
}
protected
async
_runCell
(
:
.
)
{
const
=
this
.
.
createNotebookCellExecution
(
)
;
.
start
(
.
now
(
)
)
;
.
=
1
;
await
sleep
(
10
)
;
await
.
replaceOutput
(
[
new
vscode
.
NotebookCellOutput
(
[
.
.
text
(
.
.
getText
(
)
||
.
.
.
toString
(
)
,
'text/plain'
)
]
)
]
)
;
.
end
(
true
)
;
}
}
async
function
assertKernel
(
:
,
:
.
)
:
Promise
<
void
>
{
const
=
await
.
.
executeCommand
(
'notebook.selectKernel'
,
{
:
'vscode.vscode-api-tests'
,
:
.
.
}
)
;
.
ok
(
,
` expected selected kernel to be ${ kernel. controller. id} `
)
;
.
ok
(
.
.
has
(
.
.
toString
(
)
)
)
;
}
const
:
.
=
{
serializeNotebook
(
,
)
{
return
new
Uint8Array
(
)
;
}
,
deserializeNotebook
(
,
)
{
const
:
.
=
{
:
{
:
false
}
,
:
[
{
:
'test'
,
:
'typescript'
,
:
.
.
,
:
[
]
,
:
{
:
123
}
,
:
{
:
{
:
10
,
:
20
}
}
}
,
{
:
'test2'
,
:
'typescript'
,
:
.
.
,
:
[
new
vscode
.
NotebookCellOutput
(
[
.
.
text
(
'Hello World'
,
'text/plain'
)
]
,
{
:
true
,
[
'text/plain'
]
:
{
:
true
}
}
)
]
,
:
{
:
5
,
:
true
}
,
:
{
:
456
}
}
]
}
;
return
;
}
}
;
(
.
.
===
.
.
?
.
:
)
(
'Notebook Kernel API tests'
,
function
(
)
{
const
:
.
[
]
=
[
]
;
const
:
.
[
]
=
[
]
;
suiteTeardown
(
async
function
(
)
{
assertNoRpc
(
)
;
await
revertAllDirty
(
)
;
await
closeAllEditors
(
)
;
disposeAll
(
)
;
.
=
0
;
}
)
;
suiteSetup
(
(
)
=>
{
.
push
(
.
.
registerNotebookSerializer
(
'notebookCoreTest'
,
)
)
;
}
)
;
let
:
;
setup
(
async
function
(
)
{
=
new
Kernel
(
'mainKernel'
,
'Notebook Default Kernel'
)
;
.
push
(
.
)
;
await
saveAllFilesAndCloseAll
(
)
;
}
)
;
teardown
(
async
function
(
)
{
disposeAll
(
)
;
.
=
0
;
await
saveAllFilesAndCloseAll
(
)
;
}
)
;
test
(
'cell execute command takes arguments'
,
async
(
)
=>
{
console
.
log
(
'Step1.cell execute command takes arguments'
)
;
const
=
await
openRandomNotebookDocument
(
)
;
console
.
log
(
'Step2.cell execute command takes arguments'
)
;
await
.
.
showNotebookDocument
(
)
;
console
.
log
(
'Step3.cell execute command takes arguments'
)
;
.
strictEqual
(
.
.
!==
undefined
,
true
,
'notebook first'
)
;
const
=
.
.
!
;
const
=
.
.
cellAt
(
0
)
;
console
.
log
(
'Step4.cell execute command takes arguments'
)
;
await
withEvent
(
.
.
,
async
=>
{
console
.
log
(
'Step5.cell execute command takes arguments'
)
;
await
.
.
executeCommand
(
'notebook.execute'
)
;
console
.
log
(
'Step6.cell execute command takes arguments'
)
;
await
;
console
.
log
(
'Step7.cell execute command takes arguments'
)
;
.
strictEqual
(
.
.
,
1
,
'should execute'
)
;
}
)
;
console
.
log
(
'Step8.cell execute command takes arguments'
)
;
await
withEvent
(
.
.
,
async
=>
{
console
.
log
(
'Step9.cell execute command takes arguments'
)
;
await
.
.
executeCommand
(
'notebook.cell.clearOutputs'
)
;
console
.
log
(
'Step10.cell execute command takes arguments'
)
;
await
;
console
.
log
(
'Step11.cell execute command takes arguments'
)
;
.
strictEqual
(
.
.
,
0
,
'should clear'
)
;
}
)
;
console
.
log
(
'Step12.cell execute command takes arguments'
)
;
const
=
await
createRandomNotebookFile
(
)
;
console
.
log
(
'Step13.cell execute command takes arguments'
)
;
const
=
await
.
.
openNotebookDocument
(
)
;
console
.
log
(
'Step14.cell execute command takes arguments'
)
;
await
.
.
showNotebookDocument
(
)
;
console
.
log
(
'Step15.cell execute command takes arguments'
)
;
await
withEvent < vscode. NotebookDocumentChangeEvent>
(
.
.
,
async
=>
{
console
.
log
(
'Step16.cell execute command takes arguments'
)
;
await
.
.
executeCommand
(
'notebook.cell.execute'
,
{
:
0
,
:
1
}
,
.
)
;
console
.
log
(
'Step17.cell execute command takes arguments'
)
;
await
;
console
.
log
(
'Step18.cell execute command takes arguments'
)
;
.
strictEqual
(
.
.
,
1
,
'should execute'
)
;
.
strictEqual
(
.
.
?.
.
.
,
.
)
;
}
)
;
console
.
log
(
'Step19.cell execute command takes arguments'
)
;
}
)
;
test
(
'cell execute command takes arguments 2'
,
async
(
)
=>
{
console
.
log
(
'Step1.cell execute command takes arguments 2'
)
;
const
=
await
openRandomNotebookDocument
(
)
;
console
.
log
(
'Step2.cell execute command takes arguments 2'
)
;
await
.
.
showNotebookDocument
(
)
;
console
.
log
(
'Step3.cell execute command takes arguments 2'
)
;
let
=
false
;
let
=
false
;
const
=
new
DeferredPromise< void >
(
)
;
.
push
(
.
.
onDidChangeNotebookDocument
(
=>
{
.
.
forEach
(
=>
{
if
(
.
.
===
0
&&
.
)
{
=
true
;
}
if
(
.
.
===
1
&&
.
)
{
=
true
;
}
}
)
;
if
(
&&
)
{
.
complete
(
)
;
}
}
)
)
;
await
.
.
executeCommand
(
'notebook.cell.execute'
,
{
:
.
,
:
[
{
:
0
,
:
1
}
,
{
:
1
,
:
2
}
]
}
)
;
await
.
;
await
saveAllFilesAndCloseAll
(
)
;
}
)
;
test
(
'document execute command takes arguments'
,
async
(
)
=>
{
const
=
await
openRandomNotebookDocument
(
)
;
await
.
.
showNotebookDocument
(
)
;
.
strictEqual
(
.
.
!==
undefined
,
true
,
'notebook first'
)
;
const
=
.
.
!
;
const
=
.
.
cellAt
(
0
)
;
await
withEvent < vscode. NotebookDocumentChangeEvent>
(
.
.
,
async
(
)
=>
{
await
.
.
executeCommand
(
'notebook.execute'
,
.
)
;
await
;
.
strictEqual
(
.
.
,
1
,
'should execute'
)
;
}
)
;
}
)
;
test
(
'cell execute and select kernel'
,
async
function
(
)
{
const
=
await
openRandomNotebookDocument
(
)
;
const
=
await
.
.
showNotebookDocument
(
)
;
.
strictEqual
(
.
.
===
,
true
,
'notebook first'
)
;
const
=
.
.
cellAt
(
0
)
;
const
=
new
class
extends
Kernel
{
constructor
(
)
{
super
(
'secondaryKernel'
,
'Notebook Secondary Test Kernel'
)
;
this
.
.
=
false
;
}
async
_runCell
(
:
.
)
{
const
=
this
.
.
createNotebookCellExecution
(
)
;
.
start
(
)
;
await
.
replaceOutput
(
[
new
vscode
.
NotebookCellOutput
(
[
.
.
text
(
'my second output'
,
'text/plain'
)
]
)
]
)
;
.
end
(
true
)
;
}
}
;
.
push
(
.
)
;
await
withEvent < vscode. NotebookDocumentChangeEvent>
(
.
.
,
async
(
)
=>
{
await
assertKernel
(
,
)
;
await
.
.
executeCommand
(
'notebook.cell.execute'
)
;
await
;
.
strictEqual
(
.
.
,
1
,
'should execute'
)
;
.
strictEqual
(
.
[
0
]
.
.
,
1
)
;
.
strictEqual
(
.
[
0
]
.
[
0
]
.
,
'text/plain'
)
;
.
deepStrictEqual
(
new
TextDecoder
(
)
.
decode
(
.
[
0
]
.
[
0
]
.
)
,
.
.
getText
(
)
)
;
}
)
;
await
withEvent < vscode. NotebookDocumentChangeEvent>
(
.
.
,
async
(
)
=>
{
await
assertKernel
(
,
)
;
await
.
.
executeCommand
(
'notebook.cell.execute'
)
;
await
;
.
strictEqual
(
.
.
,
1
,
'should execute'
)
;
.
strictEqual
(
.
[
0
]
.
.
,
1
)
;
.
strictEqual
(
.
[
0
]
.
[
0
]
.
,
'text/plain'
)
;
.
deepStrictEqual
(
new
TextDecoder
(
)
.
decode
(
.
[
0
]
.
[
0
]
.
)
,
'my second output'
)
;
}
)
;
}
)
;
test
(
'Output changes are applied once the promise resolves'
,
async
function
(
)
{
let
=
false
;
const
=
new
class
extends
Kernel
{
constructor
(
)
{
super
(
'verifyOutputSyncKernel'
,
''
)
;
}
async
_execute
(
:
.
[
]
)
{
const
[
]
=
;
const
=
this
.
.
createNotebookCellExecution
(
)
;
.
start
(
)
;
await
.
replaceOutput
(
[
new
vscode
.
NotebookCellOutput
(
[
.
.
text
(
'Some output'
,
'text/plain'
)
]
)
]
)
;
.
strictEqual
(
.
.
cellAt
(
0
)
.
.
,
1
)
;
.
deepStrictEqual
(
new
TextDecoder
(
)
.
decode
(
.
.
cellAt
(
0
)
.
[
0
]
.
[
0
]
.
)
,
'Some output'
)
;
.
end
(
undefined
)
;
=
true
;
}
}
;
const
=
await
openRandomNotebookDocument
(
)
;
await
.
.
showNotebookDocument
(
)
;
await
assertKernel
(
,
)
;
await
.
.
executeCommand
(
'notebook.cell.execute'
)
;
.
strictEqual
(
,
true
)
;
.
.
dispose
(
)
;
}
)
;
test
(
'executionSummary'
,
async
(
)
=>
{
const
=
await
openRandomNotebookDocument
(
)
;
const
=
await
.
.
showNotebookDocument
(
)
;
const
=
.
.
cellAt
(
0
)
;
.
strictEqual
(
.
?.
,
undefined
)
;
.
strictEqual
(
.
?.
,
undefined
)
;
await
.
.
executeCommand
(
'notebook.cell.execute'
)
;
.
strictEqual
(
.
.
,
1
,
'should execute'
)
;
.
ok
(
.
)
;
.
strictEqual
(
.
!
.
,
true
)
;
.
strictEqual
(
typeof
.
!
.
,
'number'
)
;
}
)
;
test
(
'initialize executionSummary'
,
async
(
)
=>
{
const
=
await
openRandomNotebookDocument
(
)
;
const
=
.
cellAt
(
0
)
;
.
strictEqual
(
.
?.
,
undefined
)
;
.
strictEqual
(
.
?.
?.
,
10
)
;
.
strictEqual
(
.
?.
?.
,
20
)
;
}
)
;
test
(
'execution cancelled when delete while executing'
,
async
(
)
=>
{
const
=
await
openRandomNotebookDocument
(
)
;
const
=
.
cellAt
(
0
)
;
let
=
false
;
const
=
new
class
extends
Kernel
{
constructor
(
)
{
super
(
'cancelledKernel'
,
''
)
;
}
async
_execute
(
:
.
[
]
)
{
const
[
]
=
;
const
=
this
.
.
createNotebookCellExecution
(
)
;
.
.
onCancellationRequested
(
(
)
=>
=
true
)
;
}
}
;
.
push
(
.
)
;
await
.
.
showNotebookDocument
(
)
;
await
assertKernel
(
,
)
;
await
.
.
executeCommand
(
'notebook.cell.execute'
)
;
const
=
new
vscode
.
WorkspaceEdit
(
)
;
.
set
(
!
.
.
,
[
.
.
replaceCells
(
new
vscode
.
NotebookRange
(
!
.
,
!
.
+
1
)
,
[
]
)
]
)
;
await
.
.
applyEdit
(
)
;
.
strictEqual
(
,
true
)
;
}
)
;
test
(
'appendOutput to different cell'
,
async
function
(
)
{
const
=
await
openRandomNotebookDocument
(
)
;
const
=
await
.
.
showNotebookDocument
(
)
;
const
=
.
.
cellAt
(
0
)
;
const
=
new
vscode
.
NotebookEdit
(
new
vscode
.
NotebookRange
(
1
,
1
)
,
[
new
vscode
.
NotebookCellData
(
.
.
,
'test 2'
,
'javascript'
)
]
)
;
const
=
new
vscode
.
WorkspaceEdit
(
)
;
.
set
(
.
,
[
]
)
;
await
.
.
applyEdit
(
)
;
const
=
.
.
cellAt
(
1
)
;
const
=
new
class
extends
Kernel
{
constructor
(
)
{
super
(
'nextCellKernel'
,
'Append to cell kernel'
)
;
}
async
_runCell
(
:
.
)
{
const
=
this
.
.
createNotebookCellExecution
(
)
;
.
start
(
)
;
await
.
appendOutput
(
[
new
vscode
.
NotebookCellOutput
(
[
.
.
text
(
'my output'
)
]
)
]
,
)
;
await
.
appendOutput
(
[
new
vscode
.
NotebookCellOutput
(
[
.
.
text
(
'my output 2'
)
]
)
]
,
)
;
.
end
(
true
)
;
}
}
;
.
push
(
.
)
;
await
withEvent < vscode. NotebookDocumentChangeEvent>
(
.
.
,
async
(
)
=>
{
await
assertKernel
(
,
)
;
await
.
.
executeCommand
(
'notebook.cell.execute'
)
;
await
;
.
strictEqual
(
.
.
,
0
,
'should not change cell 0'
)
;
.
strictEqual
(
.
.
,
2
,
'should update cell 1'
)
;
.
strictEqual
(
.
[
0
]
.
.
,
1
)
;
.
deepStrictEqual
(
new
TextDecoder
(
)
.
decode
(
.
[
0
]
.
[
0
]
.
)
,
'my output'
)
;
}
)
;
}
)
;
test
(
'replaceOutput to different cell'
,
async
function
(
)
{
const
=
await
openRandomNotebookDocument
(
)
;
const
=
await
.
.
showNotebookDocument
(
)
;
const
=
.
.
cellAt
(
0
)
;
const
=
new
vscode
.
NotebookEdit
(
new
vscode
.
NotebookRange
(
1
,
1
)
,
[
new
vscode
.
NotebookCellData
(
.
.
,
'test 2'
,
'javascript'
)
]
)
;
const
=
new
vscode
.
WorkspaceEdit
(
)
;
.
set
(
.
,
[
]
)
;
await
.
.
applyEdit
(
)
;
const
=
.
.
cellAt
(
1
)
;
const
=
new
class
extends
Kernel
{
constructor
(
)
{
super
(
'nextCellKernel'
,
'Replace to cell kernel'
)
;
}
async
_runCell
(
:
.
)
{
const
=
this
.
.
createNotebookCellExecution
(
)
;
.
start
(
)
;
await
.
replaceOutput
(
[
new
vscode
.
NotebookCellOutput
(
[
.
.
text
(
'my output'
)
]
)
]
,
)
;
await
.
replaceOutput
(
[
new
vscode
.
NotebookCellOutput
(
[
.
.
text
(
'my output 2'
)
]
)
]
,
)
;
.
end
(
true
)
;
}
}
;
.
push
(
.
)
;
await
withEvent < vscode. NotebookDocumentChangeEvent>
(
.
.
,
async
(
)
=>
{
await
assertKernel
(
,
)
;
await
.
.
executeCommand
(
'notebook.cell.execute'
)
;
await
;
.
strictEqual
(
.
.
,
0
,
'should not change cell 0'
)
;
.
strictEqual
(
.
.
,
1
,
'should update cell 1'
)
;
.
strictEqual
(
.
[
0
]
.
.
,
1
)
;
.
deepStrictEqual
(
new
TextDecoder
(
)
.
decode
(
.
[
0
]
.
[
0
]
.
)
,
'my output 2'
)
;
}
)
;
}
)
;
}
)
;