@codingame/monaco-vscode-notebook-service-override 6.0.3 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/package.json +2 -2
  2. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +52 -37
  3. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +5 -3
  4. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +25 -7
  5. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/media/notebookFind.css.js +1 -1
  6. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +4 -9
  7. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +9 -9
  8. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +245 -88
  9. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +1 -1
  10. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/apiActions.js +1 -1
  11. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +10 -10
  12. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.js +20 -7
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +2 -2
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +3 -13
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +13 -24
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +13 -4
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +1 -1
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +7 -7
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +10 -5
  20. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +3 -0
  21. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +10 -8
  22. package/vscode/src/vs/workbench/contrib/notebook/common/notebookProvider.js +0 -1
  23. package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +6 -3
  24. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +7 -3
@@ -28,12 +28,13 @@ import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeServi
28
28
  import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
29
29
  import { CellFoldingState, CellRevealType } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookBrowser';
30
30
  import { NotebookEditor } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/notebookEditor';
31
- import { CellKind, NotebookSetting } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
31
+ import { CellKind, NotebookSetting, NotebookCellsChangeType } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
32
32
  import { SIDE_GROUP } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
33
33
  import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
34
34
  import { LifecyclePhase } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
35
35
  import { OutlineConfigKeys, OutlineTarget, OutlineConfigCollapseItemsValues } from 'vscode/vscode/vs/workbench/services/outline/browser/outline';
36
36
  import { IOutlineService } from 'vscode/vscode/vs/workbench/services/outline/browser/outline.service';
37
+ import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
37
38
  import { Range } from 'vscode/vscode/vs/editor/common/core/range';
38
39
  import { mainWindow } from 'vscode/vscode/vs/base/browser/window';
39
40
  import { IContextMenuService } from 'vscode/vscode/vs/platform/contextview/browser/contextView.service';
@@ -42,12 +43,15 @@ import { IMenuService } from 'vscode/vscode/vs/platform/actions/common/actions.s
42
43
  import { RawContextKey, ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
43
44
  import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
44
45
  import { MenuEntryActionViewItem, createAndFillInActionBarActions } from 'vscode/vscode/vs/platform/actions/browser/menuEntryActionViewItem';
45
- import { disposableTimeout } from 'vscode/vscode/vs/base/common/async';
46
+ import { disposableTimeout, Delayer } from 'vscode/vscode/vs/base/common/async';
46
47
  import { IOutlinePane } from 'vscode/vscode/vs/workbench/contrib/outline/browser/outline';
47
48
  import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
48
49
  import { NOTEBOOK_IS_ACTIVE_EDITOR } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookContextKeys';
49
50
  import { NotebookOutlineConstants } from '../../viewModel/notebookOutlineEntryFactory.js';
50
- import { INotebookCellOutlineProviderFactory } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineProviderFactory.service';
51
+ import { INotebookCellOutlineDataSourceFactory } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineDataSourceFactory.service';
52
+ import { NotebookExecutionType } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService';
53
+ import { INotebookExecutionStateService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookExecutionStateService.service';
54
+ import { ILanguageFeaturesService } from 'vscode/vscode/vs/editor/common/services/languageFeatures';
51
55
 
52
56
  const _moduleId = "vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline";
53
57
  class NotebookOutlineTemplate {
@@ -263,29 +267,35 @@ class NotebookOutlineVirtualDelegate {
263
267
  }
264
268
  }
265
269
  let NotebookQuickPickProvider = class NotebookQuickPickProvider {
266
- constructor(_getEntries, _configurationService, _themeService) {
267
- this._getEntries = _getEntries;
270
+ constructor(notebookCellOutlineDataSourceRef, _configurationService, _themeService) {
271
+ this.notebookCellOutlineDataSourceRef = notebookCellOutlineDataSourceRef;
268
272
  this._configurationService = _configurationService;
269
273
  this._themeService = _themeService;
274
+ this._disposables = ( (new DisposableStore()));
275
+ this.gotoShowCodeCellSymbols = this._configurationService.getValue(NotebookSetting.gotoSymbolsAllSymbols);
276
+ this._disposables.add(this._configurationService.onDidChangeConfiguration(e => {
277
+ if (e.affectsConfiguration(NotebookSetting.gotoSymbolsAllSymbols)) {
278
+ this.gotoShowCodeCellSymbols = this._configurationService.getValue(NotebookSetting.gotoSymbolsAllSymbols);
279
+ }
280
+ }));
270
281
  }
271
282
  getQuickPickElements() {
272
283
  const bucket = [];
273
- for (const entry of this._getEntries()) {
284
+ for (const entry of this.notebookCellOutlineDataSourceRef?.object?.entries ?? []) {
274
285
  entry.asFlatList(bucket);
275
286
  }
276
287
  const result = [];
277
288
  const { hasFileIcons } = this._themeService.getFileIconTheme();
278
- const showSymbols = this._configurationService.getValue(NotebookSetting.gotoSymbolsAllSymbols);
279
289
  const isSymbol = (element) => !!element.symbolKind;
280
290
  const isCodeCell = (element) => (element.cell.cellKind === CellKind.Code && element.level === NotebookOutlineConstants.NonHeaderOutlineLevel);
281
291
  for (let i = 0; i < bucket.length; i++) {
282
292
  const element = bucket[i];
283
293
  const nextElement = bucket[i + 1];
284
- if (!showSymbols
294
+ if (!this.gotoShowCodeCellSymbols
285
295
  && isSymbol(element)) {
286
296
  continue;
287
297
  }
288
- if (showSymbols
298
+ if (this.gotoShowCodeCellSymbols
289
299
  && isCodeCell(element)
290
300
  && nextElement && isSymbol(nextElement)) {
291
301
  continue;
@@ -300,33 +310,76 @@ let NotebookQuickPickProvider = class NotebookQuickPickProvider {
300
310
  }
301
311
  return result;
302
312
  }
313
+ dispose() {
314
+ this._disposables.dispose();
315
+ }
303
316
  };
304
317
  NotebookQuickPickProvider = ( (__decorate([
305
318
  ( (__param(1, IConfigurationService))),
306
319
  ( (__param(2, IThemeService)))
307
320
  ], NotebookQuickPickProvider)));
308
321
  let NotebookOutlinePaneProvider = class NotebookOutlinePaneProvider {
309
- constructor(_getEntries, _configurationService) {
310
- this._getEntries = _getEntries;
322
+ constructor(outlineDataSourceRef, _configurationService) {
323
+ this.outlineDataSourceRef = outlineDataSourceRef;
311
324
  this._configurationService = _configurationService;
325
+ this._disposables = ( (new DisposableStore()));
326
+ this.showCodeCells = this._configurationService.getValue(NotebookSetting.outlineShowCodeCells);
327
+ this.showCodeCellSymbols = this._configurationService.getValue(NotebookSetting.outlineShowCodeCellSymbols);
328
+ this.showMarkdownHeadersOnly = this._configurationService.getValue(NotebookSetting.outlineShowMarkdownHeadersOnly);
329
+ this._disposables.add(this._configurationService.onDidChangeConfiguration(e => {
330
+ if (e.affectsConfiguration(NotebookSetting.outlineShowCodeCells)) {
331
+ this.showCodeCells = this._configurationService.getValue(NotebookSetting.outlineShowCodeCells);
332
+ }
333
+ if (e.affectsConfiguration(NotebookSetting.outlineShowCodeCellSymbols)) {
334
+ this.showCodeCellSymbols = this._configurationService.getValue(NotebookSetting.outlineShowCodeCellSymbols);
335
+ }
336
+ if (e.affectsConfiguration(NotebookSetting.outlineShowMarkdownHeadersOnly)) {
337
+ this.showMarkdownHeadersOnly = this._configurationService.getValue(NotebookSetting.outlineShowMarkdownHeadersOnly);
338
+ }
339
+ }));
340
+ }
341
+ getActiveEntry() {
342
+ const newActive = this.outlineDataSourceRef?.object?.activeElement;
343
+ if (!newActive) {
344
+ return undefined;
345
+ }
346
+ if (!this.filterEntry(newActive)) {
347
+ return newActive;
348
+ }
349
+ let parent = newActive.parent;
350
+ while (parent) {
351
+ if (this.filterEntry(parent)) {
352
+ parent = parent.parent;
353
+ }
354
+ else {
355
+ return parent;
356
+ }
357
+ }
358
+ return undefined;
359
+ }
360
+ filterEntry(entry) {
361
+ if ((this.showMarkdownHeadersOnly && entry.cell.cellKind === CellKind.Markup && entry.level === NotebookOutlineConstants.NonHeaderOutlineLevel) ||
362
+ (!this.showCodeCells && entry.cell.cellKind === CellKind.Code) ||
363
+ (!this.showCodeCellSymbols && entry.cell.cellKind === CellKind.Code && entry.level > NotebookOutlineConstants.NonHeaderOutlineLevel)
364
+ ) {
365
+ return true;
366
+ }
367
+ return false;
312
368
  }
313
369
  *getChildren(element) {
314
- const showCodeCells = this._configurationService.getValue(NotebookSetting.outlineShowCodeCells);
315
- const showCodeCellSymbols = this._configurationService.getValue(NotebookSetting.outlineShowCodeCellSymbols);
316
- const showMarkdownHeadersOnly = this._configurationService.getValue(NotebookSetting.outlineShowMarkdownHeadersOnly);
317
370
  const isOutline = element instanceof NotebookCellOutline;
318
- const entries = isOutline ? this._getEntries() : element.children;
371
+ const entries = isOutline ? this.outlineDataSourceRef?.object?.entries ?? [] : element.children;
319
372
  for (const entry of entries) {
320
373
  if (entry.cell.cellKind === CellKind.Markup) {
321
- if (!showMarkdownHeadersOnly) {
374
+ if (!this.showMarkdownHeadersOnly) {
322
375
  yield entry;
323
376
  }
324
377
  else if (entry.level < NotebookOutlineConstants.NonHeaderOutlineLevel) {
325
378
  yield entry;
326
379
  }
327
380
  }
328
- else if (showCodeCells && entry.cell.cellKind === CellKind.Code) {
329
- if (showCodeCellSymbols) {
381
+ else if (this.showCodeCells && entry.cell.cellKind === CellKind.Code) {
382
+ if (this.showCodeCellSymbols) {
330
383
  yield entry;
331
384
  }
332
385
  else if (entry.level === NotebookOutlineConstants.NonHeaderOutlineLevel) {
@@ -335,27 +388,39 @@ let NotebookOutlinePaneProvider = class NotebookOutlinePaneProvider {
335
388
  }
336
389
  }
337
390
  }
391
+ dispose() {
392
+ this._disposables.dispose();
393
+ }
338
394
  };
339
395
  NotebookOutlinePaneProvider = ( (__decorate([
340
396
  ( (__param(1, IConfigurationService)))
341
397
  ], NotebookOutlinePaneProvider)));
342
398
  let NotebookBreadcrumbsProvider = class NotebookBreadcrumbsProvider {
343
- constructor(_getActiveElement, _configurationService) {
344
- this._getActiveElement = _getActiveElement;
399
+ constructor(outlineDataSourceRef, _configurationService) {
400
+ this.outlineDataSourceRef = outlineDataSourceRef;
345
401
  this._configurationService = _configurationService;
402
+ this._disposables = ( (new DisposableStore()));
403
+ this.showCodeCells = this._configurationService.getValue(NotebookSetting.breadcrumbsShowCodeCells);
404
+ this._disposables.add(this._configurationService.onDidChangeConfiguration(e => {
405
+ if (e.affectsConfiguration(NotebookSetting.breadcrumbsShowCodeCells)) {
406
+ this.showCodeCells = this._configurationService.getValue(NotebookSetting.breadcrumbsShowCodeCells);
407
+ }
408
+ }));
346
409
  }
347
410
  getBreadcrumbElements() {
348
411
  const result = [];
349
- const showCodeCells = this._configurationService.getValue(NotebookSetting.breadcrumbsShowCodeCells);
350
- let candidate = this._getActiveElement();
412
+ let candidate = this.outlineDataSourceRef?.object?.activeElement;
351
413
  while (candidate) {
352
- if (showCodeCells || candidate.cell.cellKind !== CellKind.Code) {
414
+ if (this.showCodeCells || candidate.cell.cellKind !== CellKind.Code) {
353
415
  result.unshift(candidate);
354
416
  }
355
417
  candidate = candidate.parent;
356
418
  }
357
419
  return result;
358
420
  }
421
+ dispose() {
422
+ this._disposables.dispose();
423
+ }
359
424
  };
360
425
  NotebookBreadcrumbsProvider = ( (__decorate([
361
426
  ( (__param(1, IConfigurationService)))
@@ -375,46 +440,58 @@ class NotebookComparator {
375
440
  }
376
441
  }
377
442
  let NotebookCellOutline = class NotebookCellOutline {
443
+ get activeElement() {
444
+ this.checkDelayer();
445
+ if (this._target === OutlineTarget.OutlinePane) {
446
+ return this.config.treeDataSource.getActiveEntry();
447
+ }
448
+ else {
449
+ console.error('activeElement should not be called outside of the OutlinePane');
450
+ return undefined;
451
+ }
452
+ }
378
453
  get entries() {
379
- return this._outlineProviderReference?.object?.entries ?? [];
454
+ this.checkDelayer();
455
+ return this._outlineDataSourceReference?.object?.entries ?? [];
380
456
  }
381
- get activeElement() {
382
- return this._outlineProviderReference?.object?.activeElement;
457
+ get uri() {
458
+ return this._outlineDataSourceReference?.object?.uri;
459
+ }
460
+ get isEmpty() {
461
+ return this._outlineDataSourceReference?.object?.isEmpty ?? true;
462
+ }
463
+ checkDelayer() {
464
+ if (this.delayerRecomputeState.isTriggered()) {
465
+ this.delayerRecomputeState.cancel();
466
+ this.recomputeState();
467
+ }
383
468
  }
384
- constructor(_editor, _target, instantiationService, _editorService, _configurationService) {
469
+ constructor(_editor, _target, _themeService, _editorService, _instantiationService, _configurationService, _languageFeaturesService, _notebookExecutionStateService) {
385
470
  this._editor = _editor;
471
+ this._target = _target;
472
+ this._themeService = _themeService;
386
473
  this._editorService = _editorService;
387
- this._dispoables = ( (new DisposableStore()));
474
+ this._instantiationService = _instantiationService;
475
+ this._configurationService = _configurationService;
476
+ this._languageFeaturesService = _languageFeaturesService;
477
+ this._notebookExecutionStateService = _notebookExecutionStateService;
478
+ this.outlineKind = 'notebookCells';
479
+ this._disposables = ( (new DisposableStore()));
480
+ this._modelDisposables = ( (new DisposableStore()));
481
+ this._dataSourceDisposables = ( (new DisposableStore()));
388
482
  this._onDidChange = ( (new Emitter()));
389
483
  this.onDidChange = this._onDidChange.event;
390
- this._entriesDisposables = ( (new DisposableStore()));
391
- this.outlineKind = 'notebookCells';
392
- this._localDisposables = ( (new DisposableStore()));
393
- const installSelectionListener = () => {
394
- const notebookEditor = _editor.getControl();
395
- if (!notebookEditor?.hasModel()) {
396
- this._outlineProviderReference?.dispose();
397
- this._outlineProviderReference = undefined;
398
- this._localDisposables.clear();
399
- }
400
- else {
401
- this._outlineProviderReference?.dispose();
402
- this._localDisposables.clear();
403
- this._outlineProviderReference = instantiationService.invokeFunction((accessor) => accessor.get(INotebookCellOutlineProviderFactory).getOrCreate(notebookEditor, _target));
404
- this._localDisposables.add(this._outlineProviderReference.object.onDidChange(e => {
405
- this._onDidChange.fire(e);
406
- }));
407
- }
408
- };
409
- this._dispoables.add(_editor.onDidChangeModel(() => {
410
- installSelectionListener();
411
- }));
412
- installSelectionListener();
484
+ this.delayerRecomputeState = this._disposables.add(( (new Delayer(300))));
485
+ this.delayerRecomputeActive = this._disposables.add(( (new Delayer(200))));
486
+ this.delayerRecomputeSymbols = this._disposables.add(( (new Delayer(2000))));
487
+ this.gotoShowCodeCellSymbols = this._configurationService.getValue(NotebookSetting.gotoSymbolsAllSymbols);
488
+ this.outlineShowCodeCellSymbols = this._configurationService.getValue(NotebookSetting.outlineShowCodeCellSymbols);
489
+ this.initializeOutline();
413
490
  const delegate = ( (new NotebookOutlineVirtualDelegate()));
414
- const renderers = [instantiationService.createInstance(NotebookOutlineRenderer, this._editor.getControl(), _target)];
491
+ const renderers = [this._instantiationService.createInstance(NotebookOutlineRenderer, this._editor.getControl(), this._target)];
415
492
  const comparator = ( (new NotebookComparator()));
416
493
  const options = {
417
- collapseByDefault: _target === OutlineTarget.Breadcrumbs || (_target === OutlineTarget.OutlinePane && _configurationService.getValue(OutlineConfigKeys.collapseItems) === OutlineConfigCollapseItemsValues.Collapsed),
494
+ collapseByDefault: this._target === OutlineTarget.Breadcrumbs || (this._target === OutlineTarget.OutlinePane && this._configurationService.getValue(OutlineConfigKeys.collapseItems) === OutlineConfigCollapseItemsValues.Collapsed),
418
495
  expandOnlyOnTwistieClick: true,
419
496
  multipleSelectionSupport: false,
420
497
  accessibilityProvider: ( (new NotebookOutlineAccessibility())),
@@ -422,33 +499,121 @@ let NotebookCellOutline = class NotebookCellOutline {
422
499
  keyboardNavigationLabelProvider: ( (new NotebookNavigationLabelProvider()))
423
500
  };
424
501
  this.config = {
425
- treeDataSource: instantiationService.createInstance(NotebookOutlinePaneProvider, () => (this.entries ?? [])),
426
- quickPickDataSource: instantiationService.createInstance(NotebookQuickPickProvider, () => (this.entries ?? [])),
427
- breadcrumbsDataSource: instantiationService.createInstance(NotebookBreadcrumbsProvider, () => (this.activeElement)),
502
+ treeDataSource: this._treeDataSource,
503
+ quickPickDataSource: this._quickPickDataSource,
504
+ breadcrumbsDataSource: this._breadcrumbsDataSource,
428
505
  delegate,
429
506
  renderers,
430
507
  comparator,
431
508
  options
432
509
  };
433
510
  }
434
- async setFullSymbols(cancelToken) {
435
- await this._outlineProviderReference?.object?.setFullSymbols(cancelToken);
511
+ initializeOutline() {
512
+ this.setDataSources();
513
+ this.setModelListeners();
514
+ this._disposables.add(this._editor.onDidChangeModel(() => {
515
+ this.setDataSources();
516
+ this.setModelListeners();
517
+ this.computeSymbols();
518
+ }));
519
+ this._disposables.add(this._languageFeaturesService.documentSymbolProvider.onDidChange(() => {
520
+ this.delayedComputeSymbols();
521
+ }));
522
+ this._disposables.add(this._editor.onDidChangeSelection(() => {
523
+ this.delayedRecomputeActive();
524
+ }));
525
+ this._disposables.add(this._configurationService.onDidChangeConfiguration(e => {
526
+ if (e.affectsConfiguration(NotebookSetting.outlineShowMarkdownHeadersOnly) ||
527
+ e.affectsConfiguration(NotebookSetting.outlineShowCodeCells) ||
528
+ e.affectsConfiguration(NotebookSetting.outlineShowCodeCellSymbols) ||
529
+ e.affectsConfiguration(NotebookSetting.breadcrumbsShowCodeCells)) {
530
+ this.delayedRecomputeState();
531
+ }
532
+ }));
533
+ this._disposables.add(this._notebookExecutionStateService.onDidChangeExecution(e => {
534
+ if (e.type === NotebookExecutionType.cell && !!this._editor.textModel && e.affectsNotebook(this._editor.textModel?.uri)) {
535
+ this.delayedRecomputeState();
536
+ }
537
+ }));
538
+ this._disposables.add(this._configurationService.onDidChangeConfiguration(e => {
539
+ if (e.affectsConfiguration(NotebookSetting.gotoSymbolsAllSymbols) || e.affectsConfiguration(NotebookSetting.outlineShowCodeCellSymbols)) {
540
+ this.gotoShowCodeCellSymbols = this._configurationService.getValue(NotebookSetting.gotoSymbolsAllSymbols);
541
+ this.outlineShowCodeCellSymbols = this._configurationService.getValue(NotebookSetting.outlineShowCodeCellSymbols);
542
+ this.computeSymbols();
543
+ }
544
+ }));
545
+ this._disposables.add(this._themeService.onDidFileIconThemeChange(() => {
546
+ this._onDidChange.fire({});
547
+ }));
548
+ this.recomputeState();
549
+ }
550
+ setDataSources() {
551
+ const notebookEditor = this._editor.getControl();
552
+ this._outlineDataSourceReference?.dispose();
553
+ this._dataSourceDisposables.clear();
554
+ if (!notebookEditor?.hasModel()) {
555
+ this._outlineDataSourceReference = undefined;
556
+ }
557
+ else {
558
+ this._outlineDataSourceReference = this._dataSourceDisposables.add(this._instantiationService.invokeFunction((accessor) => accessor.get(INotebookCellOutlineDataSourceFactory).getOrCreate(notebookEditor)));
559
+ this._dataSourceDisposables.add(this._outlineDataSourceReference.object.onDidChange(() => {
560
+ this._onDidChange.fire({});
561
+ }));
562
+ }
563
+ this._treeDataSource = this._dataSourceDisposables.add(this._instantiationService.createInstance(NotebookOutlinePaneProvider, this._outlineDataSourceReference));
564
+ this._quickPickDataSource = this._dataSourceDisposables.add(this._instantiationService.createInstance(NotebookQuickPickProvider, this._outlineDataSourceReference));
565
+ this._breadcrumbsDataSource = this._dataSourceDisposables.add(this._instantiationService.createInstance(NotebookBreadcrumbsProvider, this._outlineDataSourceReference));
566
+ }
567
+ setModelListeners() {
568
+ this._modelDisposables.clear();
569
+ if (!this._editor.textModel) {
570
+ return;
571
+ }
572
+ if (!this.entries.length) {
573
+ this.computeSymbols();
574
+ }
575
+ this._modelDisposables.add(this._editor.textModel.onDidChangeContent(contentChanges => {
576
+ if (( (contentChanges.rawEvents.some(c => c.kind === NotebookCellsChangeType.ChangeCellContent ||
577
+ c.kind === NotebookCellsChangeType.ChangeCellInternalMetadata ||
578
+ c.kind === NotebookCellsChangeType.Move ||
579
+ c.kind === NotebookCellsChangeType.ModelChange)))) {
580
+ this.delayedRecomputeState();
581
+ }
582
+ }));
436
583
  }
437
- get uri() {
438
- return this._outlineProviderReference?.object?.uri;
584
+ async computeSymbols(cancelToken = CancellationToken.None) {
585
+ if (this._target === OutlineTarget.QuickPick && this.gotoShowCodeCellSymbols) {
586
+ await this._outlineDataSourceReference?.object?.computeFullSymbols(cancelToken);
587
+ }
588
+ else if (this._target === OutlineTarget.OutlinePane && this.outlineShowCodeCellSymbols) {
589
+ void this._outlineDataSourceReference?.object?.computeFullSymbols(cancelToken);
590
+ }
439
591
  }
440
- get isEmpty() {
441
- return this._outlineProviderReference?.object?.isEmpty ?? true;
592
+ async delayedComputeSymbols() {
593
+ this.delayerRecomputeState.cancel();
594
+ this.delayerRecomputeActive.cancel();
595
+ this.delayerRecomputeSymbols.trigger(() => { this.computeSymbols(); });
596
+ }
597
+ recomputeState() { this._outlineDataSourceReference?.object?.recomputeState(); }
598
+ delayedRecomputeState() {
599
+ this.delayerRecomputeActive.cancel();
600
+ this.delayerRecomputeState.trigger(() => { this.recomputeState(); });
601
+ }
602
+ recomputeActive() { this._outlineDataSourceReference?.object?.recomputeActive(); }
603
+ delayedRecomputeActive() {
604
+ this.delayerRecomputeActive.trigger(() => { this.recomputeActive(); });
442
605
  }
443
606
  async reveal(entry, options, sideBySide) {
607
+ const notebookEditorOptions = {
608
+ ...options,
609
+ override: this._editor.input?.editorId,
610
+ cellRevealType: CellRevealType.NearTopIfOutsideViewport,
611
+ selection: entry.position,
612
+ viewState: undefined,
613
+ };
444
614
  await this._editorService.openEditor({
445
615
  resource: entry.cell.uri,
446
- options: {
447
- ...options,
448
- override: this._editor.input?.editorId,
449
- cellRevealType: CellRevealType.NearTopIfOutsideViewport,
450
- selection: entry.position
451
- },
616
+ options: notebookEditorOptions,
452
617
  }, sideBySide ? SIDE_GROUP : undefined);
453
618
  }
454
619
  preview(entry) {
@@ -506,21 +671,23 @@ let NotebookCellOutline = class NotebookCellOutline {
506
671
  }
507
672
  dispose() {
508
673
  this._onDidChange.dispose();
509
- this._dispoables.dispose();
510
- this._entriesDisposables.dispose();
511
- this._outlineProviderReference?.dispose();
512
- this._localDisposables.dispose();
674
+ this._disposables.dispose();
675
+ this._modelDisposables.dispose();
676
+ this._dataSourceDisposables.dispose();
677
+ this._outlineDataSourceReference?.dispose();
513
678
  }
514
679
  };
515
680
  NotebookCellOutline = ( (__decorate([
516
- ( (__param(2, IInstantiationService))),
681
+ ( (__param(2, IThemeService))),
517
682
  ( (__param(3, IEditorService))),
518
- ( (__param(4, IConfigurationService)))
683
+ ( (__param(4, IInstantiationService))),
684
+ ( (__param(5, IConfigurationService))),
685
+ ( (__param(6, ILanguageFeaturesService))),
686
+ ( (__param(7, INotebookExecutionStateService)))
519
687
  ], NotebookCellOutline)));
520
688
  let NotebookOutlineCreator = class NotebookOutlineCreator {
521
- constructor(outlineService, _instantiationService, _configurationService) {
689
+ constructor(outlineService, _instantiationService) {
522
690
  this._instantiationService = _instantiationService;
523
- this._configurationService = _configurationService;
524
691
  const reg = outlineService.registerOutlineCreator(this);
525
692
  this.dispose = () => reg.dispose();
526
693
  }
@@ -528,22 +695,12 @@ let NotebookOutlineCreator = class NotebookOutlineCreator {
528
695
  return candidate.getId() === NotebookEditor.ID;
529
696
  }
530
697
  async createOutline(editor, target, cancelToken) {
531
- const outline = this._instantiationService.createInstance(NotebookCellOutline, editor, target);
532
- const showAllGotoSymbols = this._configurationService.getValue(NotebookSetting.gotoSymbolsAllSymbols);
533
- const showAllOutlineSymbols = this._configurationService.getValue(NotebookSetting.outlineShowCodeCellSymbols);
534
- if (target === OutlineTarget.QuickPick && showAllGotoSymbols) {
535
- await outline.setFullSymbols(cancelToken);
536
- }
537
- else if (target === OutlineTarget.OutlinePane && showAllOutlineSymbols) {
538
- void outline.setFullSymbols(cancelToken);
539
- }
540
- return outline;
698
+ return this._instantiationService.createInstance(NotebookCellOutline, editor, target);
541
699
  }
542
700
  };
543
701
  NotebookOutlineCreator = ( (__decorate([
544
702
  ( (__param(0, IOutlineService))),
545
- ( (__param(1, IInstantiationService))),
546
- ( (__param(2, IConfigurationService)))
703
+ ( (__param(1, IInstantiationService)))
547
704
  ], NotebookOutlineCreator)));
548
705
  const NotebookOutlineContext = {
549
706
  CellKind: ( (new RawContextKey('notebookCellKind', undefined))),
@@ -448,7 +448,7 @@ class CodeActionParticipantUtils {
448
448
  }
449
449
  });
450
450
  for (const codeActionKind of codeActionsOnSave) {
451
- const actionsToRun = await this.getActionsToRun(model, codeActionKind, excludes, languageFeaturesService, getActionProgress, token);
451
+ const actionsToRun = await CodeActionParticipantUtils.getActionsToRun(model, codeActionKind, excludes, languageFeaturesService, getActionProgress, token);
452
452
  if (token.isCancellationRequested) {
453
453
  actionsToRun.dispose();
454
454
  return;
@@ -39,7 +39,7 @@ CommandsRegistry.registerCommand('_resolveNotebookContentProvider', (accessor) =
39
39
  CommandsRegistry.registerCommand('_resolveNotebookKernels', async (accessor, args) => {
40
40
  const notebookKernelService = accessor.get(INotebookKernelService);
41
41
  const uri = URI.revive(args.uri);
42
- const kernels = notebookKernelService.getMatchingKernel({ uri, viewType: args.viewType });
42
+ const kernels = notebookKernelService.getMatchingKernel({ uri, notebookType: args.viewType });
43
43
  return ( kernels.all.map(provider => ({
44
44
  id: provider.id,
45
45
  label: provider.label,
@@ -9,8 +9,8 @@ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/c
9
9
  import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
10
10
  import { InputFocusedContextKey } from 'vscode/vscode/vs/platform/contextkey/common/contextkeys';
11
11
  import { KeybindingWeight } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
12
- import { CTX_INLINE_CHAT_FOCUSED, CTX_INLINE_CHAT_INNER_CURSOR_FIRST, CTX_INLINE_CHAT_INNER_CURSOR_LAST, CTX_INLINE_CHAT_RESPONSE_TYPES, InlineChatResponseTypes, CTX_INLINE_CHAT_HAS_AGENT } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
13
- import { CTX_NOTEBOOK_CELL_CHAT_FOCUSED, MENU_CELL_CHAT_INPUT, CTX_NOTEBOOK_CHAT_HAS_ACTIVE_REQUEST, MENU_CELL_CHAT_WIDGET, CTX_NOTEBOOK_CHAT_USER_DID_EDIT, CTX_NOTEBOOK_CHAT_OUTER_FOCUS_POSITION, MENU_CELL_CHAT_WIDGET_STATUS } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext';
12
+ import { CTX_INLINE_CHAT_FOCUSED, CTX_INLINE_CHAT_INNER_CURSOR_FIRST, CTX_INLINE_CHAT_INNER_CURSOR_LAST, CTX_INLINE_CHAT_RESPONSE_TYPE, InlineChatResponseType } from 'vscode/vscode/vs/workbench/contrib/inlineChat/common/inlineChat';
13
+ import { CTX_NOTEBOOK_CELL_CHAT_FOCUSED, MENU_CELL_CHAT_INPUT, CTX_NOTEBOOK_CHAT_HAS_ACTIVE_REQUEST, MENU_CELL_CHAT_WIDGET, CTX_NOTEBOOK_CHAT_USER_DID_EDIT, CTX_NOTEBOOK_CHAT_OUTER_FOCUS_POSITION, MENU_CELL_CHAT_WIDGET_STATUS, CTX_NOTEBOOK_CHAT_HAS_AGENT } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext';
14
14
  import { NotebookChatController } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatController';
15
15
  import { NotebookAction, NotebookCellAction, getEditorFromArgsOrActivePane, CELL_TITLE_CELL_GROUP_ID } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/coreActions';
16
16
  import { insertNewCell } from '../insertCellActions.js';
@@ -240,9 +240,9 @@ registerAction2(class extends NotebookAction {
240
240
  menu: [
241
241
  {
242
242
  id: MENU_CELL_CHAT_WIDGET_STATUS,
243
- group: 'inline',
243
+ group: '0_main',
244
244
  order: 0,
245
- when: ( (CTX_INLINE_CHAT_RESPONSE_TYPES.notEqualsTo(InlineChatResponseTypes.OnlyMessages))),
245
+ when: ( (CTX_INLINE_CHAT_RESPONSE_TYPE.notEqualsTo(InlineChatResponseType.Messages))),
246
246
  }
247
247
  ],
248
248
  f1: false
@@ -270,7 +270,7 @@ registerAction2(class extends NotebookAction {
270
270
  },
271
271
  menu: {
272
272
  id: MENU_CELL_CHAT_WIDGET_STATUS,
273
- group: 'main',
273
+ group: '0_main',
274
274
  order: 1
275
275
  },
276
276
  f1: false
@@ -339,7 +339,7 @@ registerAction2(class extends NotebookAction {
339
339
  NOTEBOOK_EDITOR_FOCUSED,
340
340
  (NOTEBOOK_EDITOR_EDITABLE.isEqualTo(true)),
341
341
  ContextKeyExpr.not(InputFocusedContextKey),
342
- CTX_INLINE_CHAT_HAS_AGENT,
342
+ CTX_NOTEBOOK_CHAT_HAS_AGENT,
343
343
  (ContextKeyExpr.or(
344
344
  (ContextKeyExpr.equals(`config.${NotebookSetting.cellChat}`, true)),
345
345
  (ContextKeyExpr.equals(`config.${NotebookSetting.cellGenerate}`, true))
@@ -356,7 +356,7 @@ registerAction2(class extends NotebookAction {
356
356
  order: -1,
357
357
  when: ( (ContextKeyExpr.and(
358
358
  (NOTEBOOK_EDITOR_EDITABLE.isEqualTo(true)),
359
- CTX_INLINE_CHAT_HAS_AGENT,
359
+ CTX_NOTEBOOK_CHAT_HAS_AGENT,
360
360
  (ContextKeyExpr.or(
361
361
  (ContextKeyExpr.equals(`config.${NotebookSetting.cellChat}`, true)),
362
362
  (ContextKeyExpr.equals(`config.${NotebookSetting.cellGenerate}`, true))
@@ -421,7 +421,7 @@ registerAction2(class extends NotebookAction {
421
421
  order: -1,
422
422
  when: ( (ContextKeyExpr.and(
423
423
  (NOTEBOOK_EDITOR_EDITABLE.isEqualTo(true)),
424
- CTX_INLINE_CHAT_HAS_AGENT,
424
+ CTX_NOTEBOOK_CHAT_HAS_AGENT,
425
425
  (ContextKeyExpr.or(
426
426
  (ContextKeyExpr.equals(`config.${NotebookSetting.cellChat}`, true)),
427
427
  (ContextKeyExpr.equals(`config.${NotebookSetting.cellGenerate}`, true))
@@ -448,7 +448,7 @@ MenuRegistry.appendMenuItem(MenuId.NotebookToolbar, {
448
448
  (NOTEBOOK_EDITOR_EDITABLE.isEqualTo(true)),
449
449
  (ContextKeyExpr.notEquals('config.notebook.insertToolbarLocation', 'betweenCells')),
450
450
  (ContextKeyExpr.notEquals('config.notebook.insertToolbarLocation', 'hidden')),
451
- CTX_INLINE_CHAT_HAS_AGENT,
451
+ CTX_NOTEBOOK_CHAT_HAS_AGENT,
452
452
  (ContextKeyExpr.or(
453
453
  (ContextKeyExpr.equals(`config.${NotebookSetting.cellChat}`, true)),
454
454
  (ContextKeyExpr.equals(`config.${NotebookSetting.cellGenerate}`, true))
@@ -573,7 +573,7 @@ registerAction2(class extends NotebookCellAction {
573
573
  order: 0,
574
574
  when: ( (ContextKeyExpr.and(
575
575
  (NOTEBOOK_EDITOR_EDITABLE.isEqualTo(true)),
576
- CTX_INLINE_CHAT_HAS_AGENT,
576
+ CTX_NOTEBOOK_CHAT_HAS_AGENT,
577
577
  NOTEBOOK_CELL_GENERATED_BY_CHAT,
578
578
  (ContextKeyExpr.equals(`config.${NotebookSetting.cellChat}`, true))
579
579
  )))
@@ -1,14 +1,18 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
3
+ import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
3
4
  import { registerWorkbenchContribution2, WorkbenchPhase } from 'vscode/vscode/vs/workbench/common/contributions';
5
+ import { ChatAgentLocation } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents';
6
+ import { IChatAgentService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatAgents.service';
4
7
  import { IChatVariablesService } from 'vscode/vscode/vs/workbench/contrib/chat/common/chatVariables.service';
5
8
  import './cellChatActions.js';
9
+ import { CTX_NOTEBOOK_CHAT_HAS_AGENT } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext';
6
10
  import { NotebookChatController } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatController';
7
11
  import { INotebookEditorService } from 'vscode/vscode/vs/workbench/contrib/notebook/browser/services/notebookEditorService.service';
8
12
 
9
- let NotebookChatVariables = class NotebookChatVariables extends Disposable {
10
- static { this.ID = 'workbench.contrib.notebookChatVariables'; }
11
- constructor(_chatVariableService, _notebookEditorService) {
13
+ let NotebookChatContribution = class NotebookChatContribution extends Disposable {
14
+ static { this.ID = 'workbench.contrib.notebookChatContribution'; }
15
+ constructor(_chatVariableService, _notebookEditorService, contextKeyService, chatAgentService) {
12
16
  super();
13
17
  this._chatVariableService = _chatVariableService;
14
18
  this._notebookEditorService = _notebookEditorService;
@@ -22,10 +26,19 @@ let NotebookChatVariables = class NotebookChatVariables extends Disposable {
22
26
  }
23
27
  return undefined;
24
28
  }));
29
+ this._ctxHasProvider = CTX_NOTEBOOK_CHAT_HAS_AGENT.bindTo(contextKeyService);
30
+ const updateNotebookAgentStatus = () => {
31
+ const hasNotebookAgent = Boolean(chatAgentService.getDefaultAgent(ChatAgentLocation.Notebook));
32
+ this._ctxHasProvider.set(hasNotebookAgent);
33
+ };
34
+ updateNotebookAgentStatus();
35
+ this._register(chatAgentService.onDidChangeAgents(updateNotebookAgentStatus));
25
36
  }
26
37
  };
27
- NotebookChatVariables = ( __decorate([
38
+ NotebookChatContribution = ( __decorate([
28
39
  ( __param(0, IChatVariablesService)),
29
- ( __param(1, INotebookEditorService))
30
- ], NotebookChatVariables));
31
- registerWorkbenchContribution2(NotebookChatVariables.ID, NotebookChatVariables, WorkbenchPhase.BlockRestore);
40
+ ( __param(1, INotebookEditorService)),
41
+ ( __param(2, IContextKeyService)),
42
+ ( __param(3, IChatAgentService))
43
+ ], NotebookChatContribution));
44
+ registerWorkbenchContribution2(NotebookChatContribution.ID, NotebookChatContribution, WorkbenchPhase.BlockRestore);
@@ -150,7 +150,7 @@ class OutputElement extends Disposable {
150
150
  this.resizeListener.clear();
151
151
  const element = this.domNode;
152
152
  if (element) {
153
- element.parentElement?.removeChild(element);
153
+ element.remove();
154
154
  this._notebookEditor.removeInset(this._diffElementViewModel, this._nestedCell, viewModel, this._diffSide);
155
155
  }
156
156
  viewModel.pickedMimeType = mimeTypes[pick];
@@ -208,7 +208,7 @@ let OutputContainer = class OutputContainer extends Disposable {
208
208
  this._outputEntries.forEach((value, key) => {
209
209
  if (this._nestedCellViewModel.outputsViewModels.indexOf(key) < 0) {
210
210
  removedKeys.push(key);
211
- this._outputContainer.removeChild(value.domNode);
211
+ value.domNode.remove();
212
212
  this._editor.removeInset(this._diffElementViewModel, this._nestedCellViewModel, key, this._diffSide);
213
213
  }
214
214
  });