@codingame/monaco-vscode-notebook-service-override 5.2.0 → 6.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 (53) hide show
  1. package/package.json +2 -2
  2. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +26 -22
  3. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +549 -0
  4. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticEditorContrib.js +133 -0
  5. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticsActions.js +58 -0
  6. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/diagnosticCellStatusBarContrib.js +65 -0
  7. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +6 -5
  8. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +29 -27
  9. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +2 -1
  10. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +2 -1
  11. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +6 -6
  12. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +10 -8
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +27 -18
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +32 -24
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +5 -3
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +2 -1
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +2 -2
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +42 -40
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +77 -57
  20. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +184 -99
  21. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +2 -1
  22. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +2 -2
  23. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +2 -2
  24. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +56 -112
  25. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.js +31 -0
  26. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +10 -14
  27. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +6 -4
  28. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +3 -2
  29. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.js +10 -8
  30. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +7 -6
  31. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +6 -4
  32. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +21 -15
  33. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +8 -6
  34. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +6 -5
  35. package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +88 -86
  36. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityHelp.js +94 -0
  37. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibleView.js +73 -0
  38. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +3 -2
  39. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +6 -6
  40. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +7 -6
  41. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +5 -3
  42. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +6 -3
  43. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +44 -17
  44. package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.js +34 -0
  45. package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +5 -3
  46. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +67 -53
  47. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +11 -3
  48. package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +11 -10
  49. package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.js +3 -2
  50. package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +5 -3
  51. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +15 -12
  52. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +4 -2
  53. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibility.js +0 -156
@@ -2,7 +2,8 @@ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import { PauseableEmitter, Emitter } from 'vscode/vscode/vs/base/common/event';
3
3
  import { Disposable, dispose } from 'vscode/vscode/vs/base/common/lifecycle';
4
4
  import { NotebookCellTextModel } from 'vscode/vscode/vs/workbench/contrib/notebook/common/model/notebookCellTextModel';
5
- import { CellUri, NotebookCellsChangeType, CellKind, diff } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
5
+ import { CellUri, NotebookCellsChangeType, CellEditType, CellKind, diff } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
6
+ import { UndoRedoElementType } from 'vscode/vscode/vs/platform/undoRedo/common/undoRedo';
6
7
  import { IUndoRedoService } from 'vscode/vscode/vs/platform/undoRedo/common/undoRedo.service';
7
8
  import { SpliceCellsEdit, CellMetadataEdit, MoveCellEdit } from './cellEdit.js';
8
9
  import { LcsDiff } from 'vscode/vscode/vs/base/common/diff/diff';
@@ -32,7 +33,7 @@ class StackOperation {
32
33
  this._operations = [];
33
34
  this._beginSelectionState = undefined;
34
35
  this._resultSelectionState = undefined;
35
- this.type = 1 ;
36
+ this.type = UndoRedoElementType.Workspace;
36
37
  this._beginSelectionState = selectionState;
37
38
  this._beginAlternativeVersionId = beginAlternativeVersionId;
38
39
  this._resultAlternativeVersionId = beginAlternativeVersionId;
@@ -57,31 +58,39 @@ class StackOperation {
57
58
  }
58
59
  async undo() {
59
60
  this._pauseableEmitter.pause();
60
- for (let i = this._operations.length - 1; i >= 0; i--) {
61
- await this._operations[i].undo();
61
+ try {
62
+ for (let i = this._operations.length - 1; i >= 0; i--) {
63
+ await this._operations[i].undo();
64
+ }
65
+ this._postUndoRedo(this._beginAlternativeVersionId);
66
+ this._pauseableEmitter.fire({
67
+ rawEvents: [],
68
+ synchronous: undefined,
69
+ versionId: this.textModel.versionId,
70
+ endSelectionState: this._beginSelectionState
71
+ });
72
+ }
73
+ finally {
74
+ this._pauseableEmitter.resume();
62
75
  }
63
- this._postUndoRedo(this._beginAlternativeVersionId);
64
- this._pauseableEmitter.fire({
65
- rawEvents: [],
66
- synchronous: undefined,
67
- versionId: this.textModel.versionId,
68
- endSelectionState: this._beginSelectionState
69
- });
70
- this._pauseableEmitter.resume();
71
76
  }
72
77
  async redo() {
73
78
  this._pauseableEmitter.pause();
74
- for (let i = 0; i < this._operations.length; i++) {
75
- await this._operations[i].redo();
79
+ try {
80
+ for (let i = 0; i < this._operations.length; i++) {
81
+ await this._operations[i].redo();
82
+ }
83
+ this._postUndoRedo(this._resultAlternativeVersionId);
84
+ this._pauseableEmitter.fire({
85
+ rawEvents: [],
86
+ synchronous: undefined,
87
+ versionId: this.textModel.versionId,
88
+ endSelectionState: this._resultSelectionState
89
+ });
90
+ }
91
+ finally {
92
+ this._pauseableEmitter.resume();
76
93
  }
77
- this._postUndoRedo(this._resultAlternativeVersionId);
78
- this._pauseableEmitter.fire({
79
- rawEvents: [],
80
- synchronous: undefined,
81
- versionId: this.textModel.versionId,
82
- endSelectionState: this._resultSelectionState
83
- });
84
- this._pauseableEmitter.resume();
85
94
  }
86
95
  }
87
96
  class NotebookOperationManager {
@@ -118,6 +127,9 @@ class NotebookOperationManager {
118
127
  }
119
128
  }
120
129
  class NotebookEventEmitter extends PauseableEmitter {
130
+ get isEmpty() {
131
+ return this._eventQueue.isEmpty();
132
+ }
121
133
  isDirtyEvent() {
122
134
  for (const e of this._eventQueue) {
123
135
  for (let i = 0; i < e.rawEvents.length; i++) {
@@ -331,7 +343,7 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
331
343
  const edits = NotebookTextModel_1.computeEdits(this, cells);
332
344
  this.applyEdits([
333
345
  ...edits,
334
- { editType: 5 , metadata }
346
+ { editType: CellEditType.DocumentMetadata, metadata }
335
347
  ], true, undefined, () => undefined, undefined, false);
336
348
  }
337
349
  static computeEdits(model, cells) {
@@ -340,7 +352,7 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
340
352
  if (commonPrefix > 0) {
341
353
  for (let i = 0; i < commonPrefix; i++) {
342
354
  edits.push({
343
- editType: 3 ,
355
+ editType: CellEditType.Metadata,
344
356
  index: i,
345
357
  metadata: cells[i].metadata ?? {}
346
358
  }, ...this._computeOutputEdit(i, model.cells[i].outputs, cells[i].outputs));
@@ -351,18 +363,18 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
351
363
  }
352
364
  const commonSuffix = this._commonSuffix(model.cells, model.cells.length - commonPrefix, commonPrefix, cells, cells.length - commonPrefix, commonPrefix);
353
365
  if (commonSuffix > 0) {
354
- edits.push({ editType: 1 , index: commonPrefix, count: model.cells.length - commonPrefix - commonSuffix, cells: cells.slice(commonPrefix, cells.length - commonSuffix) });
366
+ edits.push({ editType: CellEditType.Replace, index: commonPrefix, count: model.cells.length - commonPrefix - commonSuffix, cells: cells.slice(commonPrefix, cells.length - commonSuffix) });
355
367
  }
356
368
  else if (commonPrefix > 0) {
357
- edits.push({ editType: 1 , index: commonPrefix, count: model.cells.length - commonPrefix, cells: cells.slice(commonPrefix) });
369
+ edits.push({ editType: CellEditType.Replace, index: commonPrefix, count: model.cells.length - commonPrefix, cells: cells.slice(commonPrefix) });
358
370
  }
359
371
  else {
360
- edits.push({ editType: 1 , index: 0, count: model.cells.length, cells });
372
+ edits.push({ editType: CellEditType.Replace, index: 0, count: model.cells.length, cells });
361
373
  }
362
374
  if (commonSuffix > 0) {
363
375
  for (let i = commonSuffix; i > 0; i--) {
364
376
  edits.push({
365
- editType: 3 ,
377
+ editType: CellEditType.Metadata,
366
378
  index: model.cells.length - i,
367
379
  metadata: cells[cells.length - i].metadata ?? {}
368
380
  }, ...this._computeOutputEdit(model.cells.length - i, model.cells[model.cells.length - i].outputs, cells[cells.length - i].outputs));
@@ -374,7 +386,7 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
374
386
  if (a.length !== b.length) {
375
387
  return [
376
388
  {
377
- editType: 2 ,
389
+ editType: CellEditType.Output,
378
390
  index: index,
379
391
  outputs: b,
380
392
  append: false
@@ -386,7 +398,7 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
386
398
  }
387
399
  return ( b.map((output, i) => {
388
400
  return {
389
- editType: 7 ,
401
+ editType: CellEditType.OutputItems,
390
402
  outputId: a[i].outputId,
391
403
  items: output.outputs,
392
404
  append: false
@@ -417,10 +429,12 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
417
429
  return true;
418
430
  }
419
431
  finally {
420
- const endSelections = endSelectionsComputer();
421
- this._increaseVersionId(this._operationManager.isUndoStackEmpty() && !this._pauseableEmitter.isDirtyEvent());
422
- this._operationManager.pushStackElement(this._alternativeVersionId, endSelections);
423
- this._pauseableEmitter.fire({ rawEvents: [], versionId: this.versionId, synchronous: synchronous, endSelectionState: endSelections });
432
+ if (!this._pauseableEmitter.isEmpty) {
433
+ const endSelections = endSelectionsComputer();
434
+ this._increaseVersionId(this._operationManager.isUndoStackEmpty() && !this._pauseableEmitter.isDirtyEvent());
435
+ this._operationManager.pushStackElement(this._alternativeVersionId, endSelections);
436
+ this._pauseableEmitter.fire({ rawEvents: [], versionId: this.versionId, synchronous: synchronous, endSelectionState: endSelections });
437
+ }
424
438
  this._pauseableEmitter.resume();
425
439
  }
426
440
  }
@@ -443,15 +457,15 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
443
457
  return null;
444
458
  }
445
459
  }
446
- else if (edit.editType !== 5 ) {
460
+ else if (edit.editType !== CellEditType.DocumentMetadata) {
447
461
  throw ( new Error('Invalid cell edit'));
448
462
  }
449
463
  return {
450
464
  edit,
451
465
  cellIndex,
452
- end: ((edit.editType === 5) )
466
+ end: (edit.editType === CellEditType.DocumentMetadata)
453
467
  ? undefined
454
- : (edit.editType === 1 ? edit.index + edit.count : cellIndex),
468
+ : (edit.editType === CellEditType.Replace ? edit.index + edit.count : cellIndex),
455
469
  originalIndex: index
456
470
  };
457
471
  })).filter(isDefined);
@@ -483,7 +497,7 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
483
497
  const replaceEdits = [];
484
498
  const otherEdits = [];
485
499
  editsOnSameIndex.forEach(edit => {
486
- if (edit.edit.editType === 1 ) {
500
+ if (edit.edit.editType === CellEditType.Replace) {
487
501
  replaceEdits.push(edit);
488
502
  }
489
503
  else {
@@ -495,10 +509,10 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
495
509
  const flattenEdits = edits.flat();
496
510
  for (const { edit, cellIndex } of flattenEdits) {
497
511
  switch (edit.editType) {
498
- case 1 :
512
+ case CellEditType.Replace:
499
513
  this._replaceCells(edit.index, edit.count, edit.cells, synchronous, computeUndoRedo, beginSelectionState, undoRedoGroup);
500
514
  break;
501
- case 2 : {
515
+ case CellEditType.Output: {
502
516
  this._assertIndex(cellIndex);
503
517
  const cell = this._cells[cellIndex];
504
518
  if (edit.append) {
@@ -509,7 +523,7 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
509
523
  }
510
524
  break;
511
525
  }
512
- case 7 :
526
+ case CellEditType.OutputItems:
513
527
  {
514
528
  this._assertIndex(cellIndex);
515
529
  const cell = this._cells[cellIndex];
@@ -521,26 +535,26 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
521
535
  }
522
536
  }
523
537
  break;
524
- case 3 :
538
+ case CellEditType.Metadata:
525
539
  this._assertIndex(edit.index);
526
540
  this._changeCellMetadata(this._cells[edit.index], edit.metadata, computeUndoRedo, beginSelectionState, undoRedoGroup);
527
541
  break;
528
- case 8 :
542
+ case CellEditType.PartialMetadata:
529
543
  this._assertIndex(cellIndex);
530
544
  this._changeCellMetadataPartial(this._cells[cellIndex], edit.metadata, computeUndoRedo, beginSelectionState, undoRedoGroup);
531
545
  break;
532
- case 9 :
546
+ case CellEditType.PartialInternalMetadata:
533
547
  this._assertIndex(cellIndex);
534
548
  this._changeCellInternalMetadataPartial(this._cells[cellIndex], edit.internalMetadata);
535
549
  break;
536
- case 4 :
550
+ case CellEditType.CellLanguage:
537
551
  this._assertIndex(edit.index);
538
552
  this._changeCellLanguage(this._cells[edit.index], edit.language, computeUndoRedo, beginSelectionState, undoRedoGroup);
539
553
  break;
540
- case 5 :
554
+ case CellEditType.DocumentMetadata:
541
555
  this._updateNotebookCellMetadata(edit.metadata, computeUndoRedo, beginSelectionState, undoRedoGroup);
542
556
  break;
543
- case 6 :
557
+ case CellEditType.Move:
544
558
  this._moveCellToIdx(edit.index, edit.length, edit.newIdx, synchronous, computeUndoRedo, beginSelectionState, undefined, undoRedoGroup);
545
559
  break;
546
560
  }
@@ -551,17 +565,17 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
551
565
  rawEdits.forEach(edit => {
552
566
  if (mergedEdits.length) {
553
567
  const last = mergedEdits[mergedEdits.length - 1];
554
- if (last.edit.editType === 2
568
+ if (last.edit.editType === CellEditType.Output
555
569
  && last.edit.append
556
- && edit.edit.editType === 2
570
+ && edit.edit.editType === CellEditType.Output
557
571
  && edit.edit.append
558
572
  && last.cellIndex === edit.cellIndex) {
559
573
  last.edit.outputs = [...last.edit.outputs, ...edit.edit.outputs];
560
574
  }
561
- else if (last.edit.editType === 2
575
+ else if (last.edit.editType === CellEditType.Output
562
576
  && !last.edit.append
563
577
  && last.edit.outputs.length === 0
564
- && edit.edit.editType === 2
578
+ && edit.edit.editType === CellEditType.Output
565
579
  && edit.edit.append
566
580
  && last.cellIndex === edit.cellIndex) {
567
581
  last.edit.append = false;
@@ -674,7 +688,7 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
674
688
  const that = this;
675
689
  this._operationManager.pushEditOperation(new (class {
676
690
  constructor() {
677
- this.type = 0 ;
691
+ this.type = UndoRedoElementType.Resource;
678
692
  this.label = 'Update Cell Metadata';
679
693
  this.code = 'undoredo.textBufferEdit';
680
694
  }
@@ -865,7 +879,7 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
865
879
  const that = this;
866
880
  this._operationManager.pushEditOperation(new (class {
867
881
  constructor() {
868
- this.type = 0 ;
882
+ this.type = UndoRedoElementType.Resource;
869
883
  this.label = 'Update Cell Language';
870
884
  this.code = 'undoredo.textBufferEdit';
871
885
  }
@@ -16,14 +16,16 @@ import { NotebookProviderInfo } from './notebookProvider.js';
16
16
  import { assertIsDefined } from 'vscode/vscode/vs/base/common/types';
17
17
  import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
18
18
  import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
19
+ import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
19
20
 
20
21
  let NotebookModelReferenceCollection = class NotebookModelReferenceCollection extends ReferenceCollection {
21
- constructor(_instantiationService, _notebookService, _logService, _configurationService) {
22
+ constructor(_instantiationService, _notebookService, _logService, _configurationService, _telemetryService) {
22
23
  super();
23
24
  this._instantiationService = _instantiationService;
24
25
  this._notebookService = _notebookService;
25
26
  this._logService = _logService;
26
27
  this._configurationService = _configurationService;
28
+ this._telemetryService = _telemetryService;
27
29
  this._disposables = ( new DisposableStore());
28
30
  this._workingCopyManagers = ( new Map());
29
31
  this._modelListener = ( new Map());
@@ -50,7 +52,12 @@ let NotebookModelReferenceCollection = class NotebookModelReferenceCollection ex
50
52
  const workingCopyTypeId = NotebookWorkingCopyTypeIdentifier.create(viewType);
51
53
  let workingCopyManager = this._workingCopyManagers.get(workingCopyTypeId);
52
54
  if (!workingCopyManager) {
53
- const factory = ( new NotebookFileWorkingCopyModelFactory(viewType, this._notebookService, this._configurationService));
55
+ const factory = ( new NotebookFileWorkingCopyModelFactory(
56
+ viewType,
57
+ this._notebookService,
58
+ this._configurationService,
59
+ this._telemetryService
60
+ ));
54
61
  workingCopyManager = this._instantiationService.createInstance(FileWorkingCopyManager, workingCopyTypeId, factory, factory);
55
62
  this._workingCopyManagers.set(workingCopyTypeId, workingCopyManager);
56
63
  }
@@ -103,7 +110,8 @@ NotebookModelReferenceCollection = ( __decorate([
103
110
  ( __param(0, IInstantiationService)),
104
111
  ( __param(1, INotebookService)),
105
112
  ( __param(2, ILogService)),
106
- ( __param(3, IConfigurationService))
113
+ ( __param(3, IConfigurationService)),
114
+ ( __param(4, ITelemetryService))
107
115
  ], NotebookModelReferenceCollection));
108
116
  let NotebookModelResolverServiceImpl = class NotebookModelResolverServiceImpl {
109
117
  constructor(instantiationService, _notebookService, _extensionService, _uriIdentService) {
@@ -1,6 +1,7 @@
1
1
  import { parse } from 'vscode/vscode/vs/base/common/glob';
2
2
  import { Iterable } from 'vscode/vscode/vs/base/common/iterator';
3
3
  import { joinPath } from 'vscode/vscode/vs/base/common/resources';
4
+ import { RendererMessagingSpec, NotebookRendererMatch } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
4
5
 
5
6
  class DependencyList {
6
7
  constructor(value) {
@@ -34,32 +35,32 @@ class NotebookOutputRendererInfo {
34
35
  this.mimeTypeGlobs = ( this.mimeTypes.map(pattern => parse(pattern)));
35
36
  this.hardDependencies = ( new DependencyList(descriptor.dependencies ?? Iterable.empty()));
36
37
  this.optionalDependencies = ( new DependencyList(descriptor.optionalDependencies ?? Iterable.empty()));
37
- this.messaging = descriptor.requiresMessaging ?? "never" ;
38
+ this.messaging = descriptor.requiresMessaging ?? RendererMessagingSpec.Never;
38
39
  }
39
40
  matchesWithoutKernel(mimeType) {
40
41
  if (!this.matchesMimeTypeOnly(mimeType)) {
41
- return 3 ;
42
+ return NotebookRendererMatch.Never;
42
43
  }
43
44
  if (this.hardDependencies.defined) {
44
- return 0 ;
45
+ return NotebookRendererMatch.WithHardKernelDependency;
45
46
  }
46
47
  if (this.optionalDependencies.defined) {
47
- return 1 ;
48
+ return NotebookRendererMatch.WithOptionalKernelDependency;
48
49
  }
49
- return 2 ;
50
+ return NotebookRendererMatch.Pure;
50
51
  }
51
52
  matches(mimeType, kernelProvides) {
52
53
  if (!this.matchesMimeTypeOnly(mimeType)) {
53
- return 3 ;
54
+ return NotebookRendererMatch.Never;
54
55
  }
55
56
  if (this.hardDependencies.defined) {
56
57
  return this.hardDependencies.matches(kernelProvides)
57
- ? 0
58
- : 3 ;
58
+ ? NotebookRendererMatch.WithHardKernelDependency
59
+ : NotebookRendererMatch.Never;
59
60
  }
60
61
  return this.optionalDependencies.matches(kernelProvides)
61
- ? 1
62
- : 2 ;
62
+ ? NotebookRendererMatch.WithOptionalKernelDependency
63
+ : NotebookRendererMatch.Pure;
63
64
  }
64
65
  matchesMimeTypeOnly(mimeType) {
65
66
  if (this.entrypoint.extends) {
@@ -1,6 +1,7 @@
1
1
  import { LcsDiff } from 'vscode/vscode/vs/base/common/diff/diff';
2
2
  import { numberHash, doHash, hash } from 'vscode/vscode/vs/base/common/hash';
3
3
  import { URI } from 'vscode/vscode/vs/base/common/uri';
4
+ import { DefaultEndOfLine, EndOfLinePreference } from 'vscode/vscode/vs/editor/common/model';
4
5
  import { PieceTreeTextBufferBuilder } from 'vscode/vscode/vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBufferBuilder';
5
6
  import { NotebookCellsChangeType, CellKind } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
6
7
  import { Range } from 'vscode/vscode/vs/editor/common/core/range';
@@ -21,7 +22,7 @@ class MirrorCell {
21
22
  const builder = ( new PieceTreeTextBufferBuilder());
22
23
  builder.acceptChunk(Array.isArray(this._source) ? this._source.join('\n') : this._source);
23
24
  const bufferFactory = builder.finish(true);
24
- this._textBuffer = bufferFactory.create(1 ).textBuffer;
25
+ this._textBuffer = bufferFactory.create(DefaultEndOfLine.LF).textBuffer;
25
26
  return this._textBuffer;
26
27
  }
27
28
  primaryKey() {
@@ -47,7 +48,7 @@ class MirrorCell {
47
48
  }
48
49
  getValue() {
49
50
  const fullRange = this.getFullModelRange();
50
- return this.textBuffer.getValueInRange(fullRange, 1 );
51
+ return this.textBuffer.getValueInRange(fullRange, EndOfLinePreference.LF);
51
52
  }
52
53
  getComparisonValue() {
53
54
  if (this._primaryKey !== null) {
@@ -12,10 +12,12 @@ import { SaveSourceRegistry } from 'vscode/vscode/vs/workbench/common/editor';
12
12
  import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
13
13
  import { IPathService } from 'vscode/vscode/vs/workbench/services/path/common/pathService.service';
14
14
  import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
15
+ import { StoredFileWorkingCopyState } from 'vscode/vscode/vs/workbench/services/workingCopy/common/storedFileWorkingCopy';
15
16
  import { StoredFileWorkingCopyManager } from './storedFileWorkingCopyManager.js';
16
17
  import { UntitledFileWorkingCopy } from './untitledFileWorkingCopy.js';
17
18
  import { UntitledFileWorkingCopyManager } from './untitledFileWorkingCopyManager.js';
18
19
  import { IWorkingCopyFileService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyFileService.service';
20
+ import { SnapshotContext } from 'vscode/vscode/vs/workbench/services/workingCopy/common/fileWorkingCopy';
19
21
  import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label.service';
20
22
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
21
23
  import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification.service';
@@ -107,7 +109,7 @@ let FileWorkingCopyManager = class FileWorkingCopyManager extends Disposable {
107
109
  }
108
110
  registerListeners() {
109
111
  this._register(this.stored.onDidResolve(workingCopy => {
110
- if (workingCopy.isReadonly() || workingCopy.hasState(4 )) {
112
+ if (workingCopy.isReadonly() || workingCopy.hasState(StoredFileWorkingCopyState.ORPHAN)) {
111
113
  this._onDidChange.fire([workingCopy.resource]);
112
114
  }
113
115
  }));
@@ -121,7 +123,7 @@ let FileWorkingCopyManager = class FileWorkingCopyManager extends Disposable {
121
123
  return undefined;
122
124
  }
123
125
  const isReadonly = workingCopy.isReadonly();
124
- const isOrphaned = workingCopy.hasState(4 );
126
+ const isOrphaned = workingCopy.hasState(StoredFileWorkingCopyState.ORPHAN);
125
127
  if (isReadonly && isOrphaned) {
126
128
  return {
127
129
  color: listErrorForeground,
@@ -210,7 +212,7 @@ let FileWorkingCopyManager = class FileWorkingCopyManager extends Disposable {
210
212
  let sourceContents;
211
213
  const sourceWorkingCopy = this.get(source);
212
214
  if (sourceWorkingCopy?.isResolved()) {
213
- sourceContents = await sourceWorkingCopy.model.snapshot(1 , CancellationToken.None);
215
+ sourceContents = await sourceWorkingCopy.model.snapshot(SnapshotContext.Save, CancellationToken.None);
214
216
  }
215
217
  else {
216
218
  sourceContents = (await this.fileService.readFileStream(source)).value;
@@ -2,9 +2,10 @@ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import { localizeWithPath } from 'vscode/vscode/vs/nls';
3
3
  import { DisposableStore, dispose } from 'vscode/vscode/vs/base/common/lifecycle';
4
4
  import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
5
- import { StoredFileWorkingCopy } from 'vscode/vscode/vs/workbench/services/workingCopy/common/storedFileWorkingCopy';
5
+ import { StoredFileWorkingCopyState, StoredFileWorkingCopy } from 'vscode/vscode/vs/workbench/services/workingCopy/common/storedFileWorkingCopy';
6
6
  import { ResourceMap } from 'vscode/vscode/vs/base/common/map';
7
7
  import { ResourceQueue, Promises } from 'vscode/vscode/vs/base/common/async';
8
+ import { FileChangeType, FileOperation } from 'vscode/vscode/vs/platform/files/common/files';
8
9
  import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
9
10
  import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
10
11
  import { URI } from 'vscode/vscode/vs/base/common/uri';
@@ -24,6 +25,7 @@ import { IWorkingCopyEditorService } from 'vscode/vscode/vs/workbench/services/w
24
25
  import { IWorkingCopyService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyService.service';
25
26
  import { isWeb } from 'vscode/vscode/vs/base/common/platform';
26
27
  import { onUnexpectedError } from 'vscode/vscode/vs/base/common/errors';
28
+ import { SnapshotContext } from 'vscode/vscode/vs/workbench/services/workingCopy/common/fileWorkingCopy';
27
29
 
28
30
  const _moduleId = "vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager";
29
31
  let StoredFileWorkingCopyManager = class StoredFileWorkingCopyManager extends BaseFileWorkingCopyManager {
@@ -79,7 +81,7 @@ let StoredFileWorkingCopyManager = class StoredFileWorkingCopyManager extends Ba
79
81
  }
80
82
  onBeforeShutdownWeb() {
81
83
  if (( (this.workingCopies.some(
82
- workingCopy => workingCopy.hasState(2 )
84
+ workingCopy => workingCopy.hasState(StoredFileWorkingCopyState.PENDING_SAVE)
83
85
  )))) {
84
86
  return true;
85
87
  }
@@ -87,9 +89,9 @@ let StoredFileWorkingCopyManager = class StoredFileWorkingCopyManager extends Ba
87
89
  }
88
90
  async onWillShutdownDesktop() {
89
91
  let pendingSavedWorkingCopies;
90
- while ((pendingSavedWorkingCopies = this.workingCopies.filter(workingCopy => workingCopy.hasState(2 ))).length > 0) {
92
+ while ((pendingSavedWorkingCopies = this.workingCopies.filter(workingCopy => workingCopy.hasState(StoredFileWorkingCopyState.PENDING_SAVE))).length > 0) {
91
93
  await Promises.settled(( (pendingSavedWorkingCopies.map(
92
- workingCopy => workingCopy.joinState(2 )
94
+ workingCopy => workingCopy.joinState(StoredFileWorkingCopyState.PENDING_SAVE)
93
95
  ))));
94
96
  }
95
97
  }
@@ -115,7 +117,7 @@ let StoredFileWorkingCopyManager = class StoredFileWorkingCopyManager extends Ba
115
117
  resolveWorkingCopy = schemeOrEvent === workingCopy.resource.scheme;
116
118
  }
117
119
  else {
118
- resolveWorkingCopy = schemeOrEvent.contains(workingCopy.resource, 0 , 1 );
120
+ resolveWorkingCopy = schemeOrEvent.contains(workingCopy.resource, FileChangeType.UPDATED, FileChangeType.ADDED);
119
121
  }
120
122
  if (resolveWorkingCopy) {
121
123
  this.queueWorkingCopyReload(workingCopy);
@@ -136,7 +138,7 @@ let StoredFileWorkingCopyManager = class StoredFileWorkingCopyManager extends Ba
136
138
  }
137
139
  }
138
140
  onWillRunWorkingCopyFileOperation(e) {
139
- if (e.operation === 2 || e.operation === 3 ) {
141
+ if (e.operation === FileOperation.MOVE || e.operation === FileOperation.COPY) {
140
142
  e.waitUntil((async () => {
141
143
  const workingCopiesToRestore = [];
142
144
  for (const { source, target } of e.files) {
@@ -162,7 +164,7 @@ let StoredFileWorkingCopyManager = class StoredFileWorkingCopyManager extends Ba
162
164
  workingCopiesToRestore.push({
163
165
  source: sourceResource,
164
166
  target: targetResource,
165
- snapshot: sourceWorkingCopy.isDirty() ? await sourceWorkingCopy.model?.snapshot(1 , CancellationToken.None) : undefined
167
+ snapshot: sourceWorkingCopy.isDirty() ? await sourceWorkingCopy.model?.snapshot(SnapshotContext.Save, CancellationToken.None) : undefined
166
168
  });
167
169
  }
168
170
  }
@@ -172,7 +174,7 @@ let StoredFileWorkingCopyManager = class StoredFileWorkingCopyManager extends Ba
172
174
  }
173
175
  }
174
176
  onDidFailWorkingCopyFileOperation(e) {
175
- if (((e.operation === 2 || e.operation === 3) )) {
177
+ if ((e.operation === FileOperation.MOVE || e.operation === FileOperation.COPY)) {
176
178
  const workingCopiesToRestore = this.mapCorrelationIdToWorkingCopiesToRestore.get(e.correlationId);
177
179
  if (workingCopiesToRestore) {
178
180
  this.mapCorrelationIdToWorkingCopiesToRestore.delete(e.correlationId);
@@ -186,7 +188,7 @@ let StoredFileWorkingCopyManager = class StoredFileWorkingCopyManager extends Ba
186
188
  }
187
189
  onDidRunWorkingCopyFileOperation(e) {
188
190
  switch (e.operation) {
189
- case 0 :
191
+ case FileOperation.CREATE:
190
192
  e.waitUntil((async () => {
191
193
  for (const { target } of e.files) {
192
194
  const workingCopy = this.get(target);
@@ -196,14 +198,15 @@ let StoredFileWorkingCopyManager = class StoredFileWorkingCopyManager extends Ba
196
198
  }
197
199
  })());
198
200
  break;
199
- case 2 :
200
- case 3 :
201
+ case FileOperation.MOVE:
202
+ case FileOperation.COPY:
201
203
  e.waitUntil((async () => {
202
204
  const workingCopiesToRestore = this.mapCorrelationIdToWorkingCopiesToRestore.get(e.correlationId);
203
205
  if (workingCopiesToRestore) {
204
206
  this.mapCorrelationIdToWorkingCopiesToRestore.delete(e.correlationId);
205
207
  await Promises.settled(( (workingCopiesToRestore.map(async (workingCopyToRestore) => {
206
- await this.resolve(workingCopyToRestore.target, {
208
+ const target = this.uriIdentityService.asCanonicalUri(workingCopyToRestore.target);
209
+ await this.resolve(target, {
207
210
  reload: { async: false },
208
211
  contents: workingCopyToRestore.snapshot
209
212
  });
@@ -1,5 +1,7 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import { Emitter } from 'vscode/vscode/vs/base/common/event';
3
+ import { WorkingCopyCapabilities } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopy';
4
+ import { SnapshotContext } from 'vscode/vscode/vs/workbench/services/workingCopy/common/fileWorkingCopy';
3
5
  import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
4
6
  import { IWorkingCopyService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyService.service';
5
7
  import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
@@ -22,7 +24,7 @@ let UntitledFileWorkingCopy = class UntitledFileWorkingCopy extends Disposable {
22
24
  this.saveDelegate = saveDelegate;
23
25
  this.workingCopyBackupService = workingCopyBackupService;
24
26
  this.logService = logService;
25
- this.capabilities = this.isScratchpad ? 2 | 4 : 2 ;
27
+ this.capabilities = this.isScratchpad ? WorkingCopyCapabilities.Untitled | WorkingCopyCapabilities.Scratchpad : WorkingCopyCapabilities.Untitled;
26
28
  this._model = undefined;
27
29
  this._onDidChangeContent = this._register(( new Emitter()));
28
30
  this.onDidChangeContent = this._onDidChangeContent.event;
@@ -105,7 +107,7 @@ let UntitledFileWorkingCopy = class UntitledFileWorkingCopy extends Disposable {
105
107
  async backup(token) {
106
108
  let content = undefined;
107
109
  if (this.isResolved()) {
108
- content = await raceCancellation(this.model.snapshot(2 , token), token);
110
+ content = await raceCancellation(this.model.snapshot(SnapshotContext.Backup, token), token);
109
111
  }
110
112
  else if (this.initialContents) {
111
113
  content = this.initialContents.value;