@codingame/monaco-vscode-notebook-service-override 9.0.2 → 10.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.
- package/package.json +2 -2
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +16 -19
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +62 -63
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticsActions.js +4 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/diagnosticCellStatusBarContrib.js +5 -5
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +8 -9
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +35 -37
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +1 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +1 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +16 -17
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +17 -20
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +15 -18
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +4 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +1 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookMulticursor.js +319 -67
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +64 -61
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesDataSource.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +10 -9
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +48 -24
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +35 -37
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +45 -31
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +4 -5
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +124 -71
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebook.chat.contribution.js +179 -7
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/editActions.js +52 -55
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +30 -32
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +28 -30
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +17 -18
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/notebookIndentationActions.js +7 -7
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.js +20 -22
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +126 -46
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +171 -83
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibilityHelp.js +19 -19
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibleView.js +5 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +33 -33
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +4 -5
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +6 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +7 -8
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +3 -5
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +6 -9
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +13 -21
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +90 -39
- package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +3 -5
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +40 -31
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +7 -7
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +10 -11
- package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.js +29 -55
- package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +15 -17
- package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +12 -14
- package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +2 -4
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.js +0 -33
|
@@ -15,13 +15,12 @@ import { IAccessibilityService } from 'vscode/vscode/vs/platform/accessibility/c
|
|
|
15
15
|
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
16
16
|
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
17
17
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
18
|
-
import { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
19
18
|
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
|
|
20
19
|
import { Memento } from 'vscode/vscode/vs/workbench/common/memento';
|
|
21
20
|
import { notebooksExtensionPoint, notebookRendererExtensionPoint, notebookPreloadExtensionPoint } from '../notebookExtensionPoint.js';
|
|
22
21
|
import { NotebookDiffEditorInput } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookDiffEditorInput';
|
|
23
22
|
import { NotebookTextModel } from '../../common/model/notebookTextModel.js';
|
|
24
|
-
import { NotebookEditorPriority, NotebookSetting, CellUri,
|
|
23
|
+
import { NotebookEditorPriority, NotebookSetting, CellUri, RENDERER_EQUIVALENT_EXTENSIONS, RENDERER_NOT_AVAILABLE, MimeTypeDisplayOrder, ACCESSIBLE_NOTEBOOK_DISPLAY_ORDER, NOTEBOOK_DISPLAY_ORDER } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
25
24
|
import { NotebookEditorInput } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookEditorInput';
|
|
26
25
|
import { INotebookEditorModelResolverService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookEditorModelResolverService.service';
|
|
27
26
|
import { NotebookOutputRendererInfo, NotebookStaticPreloadInfo } from '../../common/notebookOutputRenderer.js';
|
|
@@ -56,7 +55,7 @@ let NotebookProviderInfoStore = class NotebookProviderInfoStore extends Disposab
|
|
|
56
55
|
this._contributedEditors = ( (new Map()));
|
|
57
56
|
this._contributedEditorDisposables = this._register(( (new DisposableStore())));
|
|
58
57
|
this._memento = ( (new Memento(NotebookProviderInfoStore_1.CUSTOM_EDITORS_STORAGE_ID, storageService)));
|
|
59
|
-
const mementoObject = this._memento.getMemento(
|
|
58
|
+
const mementoObject = this._memento.getMemento(0 , 1 );
|
|
60
59
|
this._editorResolverService.bufferChangeEvents(() => {
|
|
61
60
|
for (const info of (mementoObject[NotebookProviderInfoStore_1.CUSTOM_EDITORS_ENTRY_ID] || [])) {
|
|
62
61
|
this.add(( (new NotebookProviderInfo(info))), false);
|
|
@@ -109,12 +108,12 @@ let NotebookProviderInfoStore = class NotebookProviderInfoStore extends Disposab
|
|
|
109
108
|
}))));
|
|
110
109
|
}
|
|
111
110
|
}
|
|
112
|
-
const mementoObject = this._memento.getMemento(
|
|
111
|
+
const mementoObject = this._memento.getMemento(0 , 1 );
|
|
113
112
|
mementoObject[NotebookProviderInfoStore_1.CUSTOM_EDITORS_ENTRY_ID] = Array.from(( (this._contributedEditors.values())));
|
|
114
113
|
this._memento.saveMemento();
|
|
115
114
|
}
|
|
116
115
|
clearEditorCache() {
|
|
117
|
-
const mementoObject = this._memento.getMemento(
|
|
116
|
+
const mementoObject = this._memento.getMemento(0 , 1 );
|
|
118
117
|
mementoObject[NotebookProviderInfoStore_1.CUSTOM_EDITORS_ENTRY_ID] = [];
|
|
119
118
|
this._memento.saveMemento();
|
|
120
119
|
}
|
|
@@ -247,12 +246,12 @@ let NotebookProviderInfoStore = class NotebookProviderInfoStore extends Disposab
|
|
|
247
246
|
this._contributedEditorDisposables.add(editorRegistration);
|
|
248
247
|
}
|
|
249
248
|
if (saveMemento) {
|
|
250
|
-
const mementoObject = this._memento.getMemento(
|
|
249
|
+
const mementoObject = this._memento.getMemento(0 , 1 );
|
|
251
250
|
mementoObject[NotebookProviderInfoStore_1.CUSTOM_EDITORS_ENTRY_ID] = Array.from(( (this._contributedEditors.values())));
|
|
252
251
|
this._memento.saveMemento();
|
|
253
252
|
}
|
|
254
253
|
return this._register(toDisposable(() => {
|
|
255
|
-
const mementoObject = this._memento.getMemento(
|
|
254
|
+
const mementoObject = this._memento.getMemento(0 , 1 );
|
|
256
255
|
mementoObject[NotebookProviderInfoStore_1.CUSTOM_EDITORS_ENTRY_ID] = Array.from(( (this._contributedEditors.values())));
|
|
257
256
|
this._memento.saveMemento();
|
|
258
257
|
editorRegistration?.dispose();
|
|
@@ -292,7 +291,7 @@ let NotebookOutputRendererInfoStore = class NotebookOutputRendererInfoStore {
|
|
|
292
291
|
constructor(storageService) {
|
|
293
292
|
this.contributedRenderers = ( (new Map()));
|
|
294
293
|
this.preferredMimetype = ( (new Lazy(
|
|
295
|
-
() => this.preferredMimetypeMemento.getMemento(
|
|
294
|
+
() => this.preferredMimetypeMemento.getMemento(1 , 1 )
|
|
296
295
|
)));
|
|
297
296
|
this.preferredMimetypeMemento = ( (new Memento('workbench.editor.notebook.preferredRenderer2', storageService)));
|
|
298
297
|
}
|
|
@@ -323,13 +322,6 @@ let NotebookOutputRendererInfoStore = class NotebookOutputRendererInfoStore {
|
|
|
323
322
|
this.preferredMimetypeMemento.saveMemento();
|
|
324
323
|
}
|
|
325
324
|
findBestRenderers(notebookProviderInfo, mimeType, kernelProvides) {
|
|
326
|
-
let ReuseOrder;
|
|
327
|
-
( ((function(ReuseOrder) {
|
|
328
|
-
ReuseOrder[ReuseOrder["PreviouslySelected"] = 256] = "PreviouslySelected";
|
|
329
|
-
ReuseOrder[ReuseOrder["SameExtensionAsNotebook"] = 512] = "SameExtensionAsNotebook";
|
|
330
|
-
ReuseOrder[ReuseOrder["OtherRenderer"] = 768] = "OtherRenderer";
|
|
331
|
-
ReuseOrder[ReuseOrder["BuiltIn"] = 1024] = "BuiltIn";
|
|
332
|
-
})(ReuseOrder || (ReuseOrder = {}))));
|
|
333
325
|
const preferred = notebookProviderInfo && this.preferredMimetype.value[notebookProviderInfo.id]?.[mimeType];
|
|
334
326
|
const notebookExtId = notebookProviderInfo?.extension?.value;
|
|
335
327
|
const notebookId = notebookProviderInfo?.id;
|
|
@@ -338,15 +330,15 @@ let NotebookOutputRendererInfoStore = class NotebookOutputRendererInfoStore {
|
|
|
338
330
|
const ownScore = kernelProvides === undefined
|
|
339
331
|
? renderer.matchesWithoutKernel(mimeType)
|
|
340
332
|
: renderer.matches(mimeType, kernelProvides);
|
|
341
|
-
if (ownScore ===
|
|
333
|
+
if (ownScore === 3 ) {
|
|
342
334
|
return undefined;
|
|
343
335
|
}
|
|
344
336
|
const rendererExtId = renderer.extensionId.value;
|
|
345
337
|
const reuseScore = preferred === renderer.id
|
|
346
|
-
?
|
|
338
|
+
? 256
|
|
347
339
|
: rendererExtId === notebookExtId || RENDERER_EQUIVALENT_EXTENSIONS.get(rendererExtId)?.has(notebookId)
|
|
348
|
-
?
|
|
349
|
-
: renderer.isBuiltin ?
|
|
340
|
+
? 512
|
|
341
|
+
: renderer.isBuiltin ? 1024 : 768 ;
|
|
350
342
|
return {
|
|
351
343
|
ordered: { mimeType, rendererId: renderer.id, isTrusted: true },
|
|
352
344
|
score: reuseScore | ownScore,
|
|
@@ -486,7 +478,7 @@ let NotebookService = class NotebookService extends Disposable {
|
|
|
486
478
|
updateOrder();
|
|
487
479
|
}));
|
|
488
480
|
this._memento = ( (new Memento(NotebookService_1._storageNotebookViewTypeProvider, this._storageService)));
|
|
489
|
-
this._viewTypeCache = this._memento.getMemento(
|
|
481
|
+
this._viewTypeCache = this._memento.getMemento(1 , 1 );
|
|
490
482
|
}
|
|
491
483
|
getEditorTypes() {
|
|
492
484
|
return (
|
|
@@ -554,7 +546,7 @@ let NotebookService = class NotebookService extends Disposable {
|
|
|
554
546
|
const knownProvider = this.getViewTypeProvider(viewType);
|
|
555
547
|
const actions = knownProvider ? [
|
|
556
548
|
toAction({
|
|
557
|
-
id: 'workbench.notebook.action.installMissingViewType', label: ( localize(
|
|
549
|
+
id: 'workbench.notebook.action.installMissingViewType', label: ( localize(3293, "Install extension for '{0}'", viewType)), run: async () => {
|
|
558
550
|
await this._instantiationService.createInstance(InstallRecommendedExtensionAction, knownProvider).run();
|
|
559
551
|
}
|
|
560
552
|
})
|
package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
2
|
import { Disposable, DisposableStore, toDisposable, dispose } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
3
3
|
import { createWebWorker } from 'vscode/vscode/vs/base/browser/defaultWorkerFactory';
|
|
4
|
-
import { NotebookCellsChangeType } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
4
|
+
import { CellUri, NotebookCellsChangeType } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
5
5
|
import { INotebookService } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookService.service';
|
|
6
|
+
import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
|
|
7
|
+
import { TextModel } from 'vscode/vscode/vs/editor/common/model/textModel';
|
|
8
|
+
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
9
|
+
import { isEqual } from 'vscode/vscode/vs/base/common/resources';
|
|
6
10
|
|
|
7
11
|
let NotebookEditorWorkerServiceImpl = class NotebookEditorWorkerServiceImpl extends Disposable {
|
|
8
|
-
constructor(notebookService) {
|
|
12
|
+
constructor(notebookService, modelService) {
|
|
9
13
|
super();
|
|
10
|
-
this._workerManager = this._register(( new WorkerManager(notebookService)));
|
|
14
|
+
this._workerManager = this._register(( new WorkerManager(notebookService, modelService)));
|
|
11
15
|
}
|
|
12
16
|
canComputeDiff(original, modified) {
|
|
13
17
|
throw ( new Error('Method not implemented.'));
|
|
@@ -24,26 +28,29 @@ let NotebookEditorWorkerServiceImpl = class NotebookEditorWorkerServiceImpl exte
|
|
|
24
28
|
}
|
|
25
29
|
};
|
|
26
30
|
NotebookEditorWorkerServiceImpl = ( __decorate([
|
|
27
|
-
( __param(0, INotebookService))
|
|
31
|
+
( __param(0, INotebookService)),
|
|
32
|
+
( __param(1, IModelService))
|
|
28
33
|
], NotebookEditorWorkerServiceImpl));
|
|
29
34
|
class WorkerManager extends Disposable {
|
|
30
|
-
constructor(_notebookService) {
|
|
35
|
+
constructor(_notebookService, _modelService) {
|
|
31
36
|
super();
|
|
32
37
|
this._notebookService = _notebookService;
|
|
38
|
+
this._modelService = _modelService;
|
|
33
39
|
this._editorWorkerClient = null;
|
|
34
40
|
}
|
|
35
41
|
withWorker() {
|
|
36
42
|
if (!this._editorWorkerClient) {
|
|
37
|
-
this._editorWorkerClient = ( new NotebookWorkerClient(this._notebookService));
|
|
43
|
+
this._editorWorkerClient = ( new NotebookWorkerClient(this._notebookService, this._modelService));
|
|
38
44
|
}
|
|
39
45
|
return Promise.resolve(this._editorWorkerClient);
|
|
40
46
|
}
|
|
41
47
|
}
|
|
42
48
|
class NotebookEditorModelManager extends Disposable {
|
|
43
|
-
constructor(_proxy, _notebookService) {
|
|
49
|
+
constructor(_proxy, _notebookService, _modelService) {
|
|
44
50
|
super();
|
|
45
51
|
this._proxy = _proxy;
|
|
46
52
|
this._notebookService = _notebookService;
|
|
53
|
+
this._modelService = _modelService;
|
|
47
54
|
this._syncedModels = Object.create(null);
|
|
48
55
|
this._syncedModelsLastUsedTime = Object.create(null);
|
|
49
56
|
}
|
|
@@ -64,28 +71,27 @@ class NotebookEditorModelManager extends Disposable {
|
|
|
64
71
|
return;
|
|
65
72
|
}
|
|
66
73
|
const modelUrl = ( resource.toString());
|
|
67
|
-
this._proxy.$acceptNewModel(( model.uri.toString()), {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
metadata: model.metadata
|
|
81
|
-
});
|
|
74
|
+
this._proxy.$acceptNewModel(( model.uri.toString()), model.metadata, ( model.cells.map(cell => ({
|
|
75
|
+
handle: cell.handle,
|
|
76
|
+
url: ( cell.uri.toString()),
|
|
77
|
+
source: cell.textBuffer.getLinesContent(),
|
|
78
|
+
eol: cell.textBuffer.getEOL(),
|
|
79
|
+
versionId: cell.textModel?.getVersionId() ?? 0,
|
|
80
|
+
language: cell.language,
|
|
81
|
+
mime: cell.mime,
|
|
82
|
+
cellKind: cell.cellKind,
|
|
83
|
+
outputs: ( cell.outputs.map(op => ({ outputId: op.outputId, outputs: op.outputs }))),
|
|
84
|
+
metadata: cell.metadata,
|
|
85
|
+
internalMetadata: cell.internalMetadata,
|
|
86
|
+
}))));
|
|
82
87
|
const toDispose = ( new DisposableStore());
|
|
83
88
|
const cellToDto = (cell) => {
|
|
84
89
|
return {
|
|
85
90
|
handle: cell.handle,
|
|
86
|
-
|
|
91
|
+
url: ( cell.uri.toString()),
|
|
87
92
|
source: cell.textBuffer.getLinesContent(),
|
|
88
93
|
eol: cell.textBuffer.getEOL(),
|
|
94
|
+
versionId: 0,
|
|
89
95
|
language: cell.language,
|
|
90
96
|
cellKind: cell.cellKind,
|
|
91
97
|
outputs: ( cell.outputs.map(op => ({ outputId: op.outputId, outputs: op.outputs }))),
|
|
@@ -93,26 +99,70 @@ class NotebookEditorModelManager extends Disposable {
|
|
|
93
99
|
internalMetadata: cell.internalMetadata,
|
|
94
100
|
};
|
|
95
101
|
};
|
|
102
|
+
const cellHandlers = ( new Set());
|
|
103
|
+
const addCellContentChangeHandler = (cell) => {
|
|
104
|
+
cellHandlers.add(cell);
|
|
105
|
+
toDispose.add(cell.onDidChangeContent((e) => {
|
|
106
|
+
if (typeof e === 'object' && e.type === 'model') {
|
|
107
|
+
this._proxy.$acceptCellModelChanged(modelUrl, cell.handle, e.event);
|
|
108
|
+
}
|
|
109
|
+
}));
|
|
110
|
+
};
|
|
111
|
+
model.cells.forEach(cell => addCellContentChangeHandler(cell));
|
|
112
|
+
if (model.cells.length !== cellHandlers.size) {
|
|
113
|
+
toDispose.add(this._modelService.onModelAdded((textModel) => {
|
|
114
|
+
if (textModel.uri.scheme !== Schemas.vscodeNotebookCell || !(textModel instanceof TextModel)) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const cellUri = CellUri.parse(textModel.uri);
|
|
118
|
+
if (!cellUri || !isEqual(cellUri.notebook, model.uri)) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const cell = model.cells.find(cell => cell.handle === cellUri.handle);
|
|
122
|
+
if (cell) {
|
|
123
|
+
addCellContentChangeHandler(cell);
|
|
124
|
+
}
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
96
127
|
toDispose.add(model.onDidChangeContent((event) => {
|
|
97
|
-
const dto =
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
: (e.kind === NotebookCellsChangeType.Move
|
|
105
|
-
? {
|
|
128
|
+
const dto = [];
|
|
129
|
+
event.rawEvents
|
|
130
|
+
.forEach(e => {
|
|
131
|
+
switch (e.kind) {
|
|
132
|
+
case NotebookCellsChangeType.ModelChange:
|
|
133
|
+
case NotebookCellsChangeType.Initialize: {
|
|
134
|
+
dto.push({
|
|
106
135
|
kind: e.kind,
|
|
136
|
+
changes: ( e.changes.map(diff => [diff[0], diff[1], ( diff[2].map(cell => cellToDto(cell)))]))
|
|
137
|
+
});
|
|
138
|
+
for (const change of e.changes) {
|
|
139
|
+
for (const cell of change[2]) {
|
|
140
|
+
addCellContentChangeHandler(cell);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
case NotebookCellsChangeType.Move: {
|
|
146
|
+
dto.push({
|
|
147
|
+
kind: NotebookCellsChangeType.Move,
|
|
107
148
|
index: e.index,
|
|
108
149
|
length: e.length,
|
|
109
150
|
newIdx: e.newIdx,
|
|
110
|
-
versionId: event.versionId,
|
|
111
151
|
cells: ( e.cells.map(cell => cellToDto(cell)))
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
152
|
+
});
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
case NotebookCellsChangeType.ChangeCellContent:
|
|
156
|
+
break;
|
|
157
|
+
case NotebookCellsChangeType.ChangeDocumentMetadata:
|
|
158
|
+
dto.push({
|
|
159
|
+
kind: e.kind,
|
|
160
|
+
metadata: e.metadata
|
|
161
|
+
});
|
|
162
|
+
default:
|
|
163
|
+
dto.push(e);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
116
166
|
this._proxy.$acceptModelChanged(( modelUrl.toString()), {
|
|
117
167
|
rawEvents: dto,
|
|
118
168
|
versionId: event.versionId
|
|
@@ -134,9 +184,10 @@ class NotebookEditorModelManager extends Disposable {
|
|
|
134
184
|
}
|
|
135
185
|
}
|
|
136
186
|
class NotebookWorkerClient extends Disposable {
|
|
137
|
-
constructor(_notebookService) {
|
|
187
|
+
constructor(_notebookService, _modelService) {
|
|
138
188
|
super();
|
|
139
189
|
this._notebookService = _notebookService;
|
|
190
|
+
this._modelService = _modelService;
|
|
140
191
|
this._worker = null;
|
|
141
192
|
this._modelManager = null;
|
|
142
193
|
}
|
|
@@ -150,7 +201,7 @@ class NotebookWorkerClient extends Disposable {
|
|
|
150
201
|
}
|
|
151
202
|
_getOrCreateModelManager(proxy) {
|
|
152
203
|
if (!this._modelManager) {
|
|
153
|
-
this._modelManager = this._register(( new NotebookEditorModelManager(proxy, this._notebookService)));
|
|
204
|
+
this._modelManager = this._register(( new NotebookEditorModelManager(proxy, this._notebookService, this._modelService)));
|
|
154
205
|
}
|
|
155
206
|
return this._modelManager;
|
|
156
207
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { UndoRedoElementType } from 'vscode/vscode/vs/platform/undoRedo/common/undoRedo';
|
|
2
|
-
|
|
3
1
|
class MoveCellEdit {
|
|
4
2
|
get label() {
|
|
5
3
|
return this.length === 1 ? 'Move Cell' : 'Move Cells';
|
|
@@ -12,7 +10,7 @@ class MoveCellEdit {
|
|
|
12
10
|
this.editingDelegate = editingDelegate;
|
|
13
11
|
this.beforedSelections = beforedSelections;
|
|
14
12
|
this.endSelections = endSelections;
|
|
15
|
-
this.type =
|
|
13
|
+
this.type = 0 ;
|
|
16
14
|
this.code = 'undoredo.textBufferEdit';
|
|
17
15
|
}
|
|
18
16
|
undo() {
|
|
@@ -44,7 +42,7 @@ class SpliceCellsEdit {
|
|
|
44
42
|
this.editingDelegate = editingDelegate;
|
|
45
43
|
this.beforeHandles = beforeHandles;
|
|
46
44
|
this.endHandles = endHandles;
|
|
47
|
-
this.type =
|
|
45
|
+
this.type = 0 ;
|
|
48
46
|
this.code = 'undoredo.textBufferEdit';
|
|
49
47
|
}
|
|
50
48
|
undo() {
|
|
@@ -71,7 +69,7 @@ class CellMetadataEdit {
|
|
|
71
69
|
this.oldMetadata = oldMetadata;
|
|
72
70
|
this.newMetadata = newMetadata;
|
|
73
71
|
this.editingDelegate = editingDelegate;
|
|
74
|
-
this.type =
|
|
72
|
+
this.type = 0 ;
|
|
75
73
|
this.label = 'Update Cell Metadata';
|
|
76
74
|
this.code = 'undoredo.textBufferEdit';
|
|
77
75
|
}
|
|
@@ -2,8 +2,7 @@ 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,
|
|
6
|
-
import { UndoRedoElementType } from 'vscode/vscode/vs/platform/undoRedo/common/undoRedo';
|
|
5
|
+
import { CellUri, NotebookCellsChangeType, CellKind, diff } from 'vscode/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
7
6
|
import { IUndoRedoService } from 'vscode/vscode/vs/platform/undoRedo/common/undoRedo.service';
|
|
8
7
|
import { SpliceCellsEdit, CellMetadataEdit, MoveCellEdit } from './cellEdit.js';
|
|
9
8
|
import { LcsDiff } from 'vscode/vscode/vs/base/common/diff/diff';
|
|
@@ -35,7 +34,7 @@ class StackOperation {
|
|
|
35
34
|
this._operations = [];
|
|
36
35
|
this._beginSelectionState = undefined;
|
|
37
36
|
this._resultSelectionState = undefined;
|
|
38
|
-
this.type =
|
|
37
|
+
this.type = 1 ;
|
|
39
38
|
this._beginSelectionState = selectionState;
|
|
40
39
|
this._beginAlternativeVersionId = beginAlternativeVersionId;
|
|
41
40
|
this._resultAlternativeVersionId = beginAlternativeVersionId;
|
|
@@ -277,7 +276,7 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
|
|
|
277
276
|
}
|
|
278
277
|
}
|
|
279
278
|
_bindCellContentHandler(cell, e) {
|
|
280
|
-
this._increaseVersionId(e === 'content');
|
|
279
|
+
this._increaseVersionId(e === 'content' || (typeof e === 'object' && e.type === 'model'));
|
|
281
280
|
switch (e) {
|
|
282
281
|
case 'content':
|
|
283
282
|
this._pauseableEmitter.fire({
|
|
@@ -303,6 +302,16 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
|
|
|
303
302
|
endSelectionState: undefined
|
|
304
303
|
});
|
|
305
304
|
break;
|
|
305
|
+
default:
|
|
306
|
+
if (typeof e === 'object' && e.type === 'model') {
|
|
307
|
+
this._pauseableEmitter.fire({
|
|
308
|
+
rawEvents: [{ kind: NotebookCellsChangeType.ChangeCellContent, index: this._getCellIndexByHandle(cell.handle), transient: false }],
|
|
309
|
+
versionId: this.versionId,
|
|
310
|
+
synchronous: true,
|
|
311
|
+
endSelectionState: undefined
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
break;
|
|
306
315
|
}
|
|
307
316
|
}
|
|
308
317
|
_generateAlternativeId() {
|
|
@@ -348,7 +357,7 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
|
|
|
348
357
|
const edits = NotebookTextModel_1.computeEdits(this, cells);
|
|
349
358
|
this.applyEdits([
|
|
350
359
|
...edits,
|
|
351
|
-
{ editType:
|
|
360
|
+
{ editType: 5 , metadata }
|
|
352
361
|
], true, undefined, () => undefined, undefined, false);
|
|
353
362
|
}
|
|
354
363
|
static computeEdits(model, cells) {
|
|
@@ -357,7 +366,7 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
|
|
|
357
366
|
if (commonPrefix > 0) {
|
|
358
367
|
for (let i = 0; i < commonPrefix; i++) {
|
|
359
368
|
edits.push({
|
|
360
|
-
editType:
|
|
369
|
+
editType: 3 ,
|
|
361
370
|
index: i,
|
|
362
371
|
metadata: cells[i].metadata ?? {}
|
|
363
372
|
}, ...this._computeOutputEdit(i, model.cells[i].outputs, cells[i].outputs));
|
|
@@ -368,18 +377,18 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
|
|
|
368
377
|
}
|
|
369
378
|
const commonSuffix = this._commonSuffix(model.cells, model.cells.length - commonPrefix, commonPrefix, cells, cells.length - commonPrefix, commonPrefix);
|
|
370
379
|
if (commonSuffix > 0) {
|
|
371
|
-
edits.push({ editType:
|
|
380
|
+
edits.push({ editType: 1 , index: commonPrefix, count: model.cells.length - commonPrefix - commonSuffix, cells: cells.slice(commonPrefix, cells.length - commonSuffix) });
|
|
372
381
|
}
|
|
373
382
|
else if (commonPrefix > 0) {
|
|
374
|
-
edits.push({ editType:
|
|
383
|
+
edits.push({ editType: 1 , index: commonPrefix, count: model.cells.length - commonPrefix, cells: cells.slice(commonPrefix) });
|
|
375
384
|
}
|
|
376
385
|
else {
|
|
377
|
-
edits.push({ editType:
|
|
386
|
+
edits.push({ editType: 1 , index: 0, count: model.cells.length, cells });
|
|
378
387
|
}
|
|
379
388
|
if (commonSuffix > 0) {
|
|
380
389
|
for (let i = commonSuffix; i > 0; i--) {
|
|
381
390
|
edits.push({
|
|
382
|
-
editType:
|
|
391
|
+
editType: 3 ,
|
|
383
392
|
index: model.cells.length - i,
|
|
384
393
|
metadata: cells[cells.length - i].metadata ?? {}
|
|
385
394
|
}, ...this._computeOutputEdit(model.cells.length - i, model.cells[model.cells.length - i].outputs, cells[cells.length - i].outputs));
|
|
@@ -391,7 +400,7 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
|
|
|
391
400
|
if (a.length !== b.length) {
|
|
392
401
|
return [
|
|
393
402
|
{
|
|
394
|
-
editType:
|
|
403
|
+
editType: 2 ,
|
|
395
404
|
index: index,
|
|
396
405
|
outputs: b,
|
|
397
406
|
append: false
|
|
@@ -403,7 +412,7 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
|
|
|
403
412
|
}
|
|
404
413
|
return ( b.map((output, i) => {
|
|
405
414
|
return {
|
|
406
|
-
editType:
|
|
415
|
+
editType: 7 ,
|
|
407
416
|
outputId: a[i].outputId,
|
|
408
417
|
items: output.outputs,
|
|
409
418
|
append: false
|
|
@@ -462,15 +471,15 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
|
|
|
462
471
|
return null;
|
|
463
472
|
}
|
|
464
473
|
}
|
|
465
|
-
else if (edit.editType !==
|
|
474
|
+
else if (edit.editType !== 5 ) {
|
|
466
475
|
throw ( new Error('Invalid cell edit'));
|
|
467
476
|
}
|
|
468
477
|
return {
|
|
469
478
|
edit,
|
|
470
479
|
cellIndex,
|
|
471
|
-
end: (edit.editType ===
|
|
480
|
+
end: ((edit.editType === 5) )
|
|
472
481
|
? undefined
|
|
473
|
-
: (edit.editType ===
|
|
482
|
+
: (edit.editType === 1 ? edit.index + edit.count : cellIndex),
|
|
474
483
|
originalIndex: index
|
|
475
484
|
};
|
|
476
485
|
})).filter(isDefined);
|
|
@@ -502,7 +511,7 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
|
|
|
502
511
|
const replaceEdits = [];
|
|
503
512
|
const otherEdits = [];
|
|
504
513
|
editsOnSameIndex.forEach(edit => {
|
|
505
|
-
if (edit.edit.editType ===
|
|
514
|
+
if (edit.edit.editType === 1 ) {
|
|
506
515
|
replaceEdits.push(edit);
|
|
507
516
|
}
|
|
508
517
|
else {
|
|
@@ -514,10 +523,10 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
|
|
|
514
523
|
const flattenEdits = edits.flat();
|
|
515
524
|
for (const { edit, cellIndex } of flattenEdits) {
|
|
516
525
|
switch (edit.editType) {
|
|
517
|
-
case
|
|
526
|
+
case 1 :
|
|
518
527
|
this._replaceCells(edit.index, edit.count, edit.cells, synchronous, computeUndoRedo, beginSelectionState, undoRedoGroup);
|
|
519
528
|
break;
|
|
520
|
-
case
|
|
529
|
+
case 2 : {
|
|
521
530
|
this._assertIndex(cellIndex);
|
|
522
531
|
const cell = this._cells[cellIndex];
|
|
523
532
|
if (edit.append) {
|
|
@@ -528,7 +537,7 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
|
|
|
528
537
|
}
|
|
529
538
|
break;
|
|
530
539
|
}
|
|
531
|
-
case
|
|
540
|
+
case 7 :
|
|
532
541
|
{
|
|
533
542
|
this._assertIndex(cellIndex);
|
|
534
543
|
const cell = this._cells[cellIndex];
|
|
@@ -540,26 +549,26 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
|
|
|
540
549
|
}
|
|
541
550
|
}
|
|
542
551
|
break;
|
|
543
|
-
case
|
|
552
|
+
case 3 :
|
|
544
553
|
this._assertIndex(edit.index);
|
|
545
554
|
this._changeCellMetadata(this._cells[edit.index], edit.metadata, computeUndoRedo, beginSelectionState, undoRedoGroup);
|
|
546
555
|
break;
|
|
547
|
-
case
|
|
556
|
+
case 8 :
|
|
548
557
|
this._assertIndex(cellIndex);
|
|
549
558
|
this._changeCellMetadataPartial(this._cells[cellIndex], edit.metadata, computeUndoRedo, beginSelectionState, undoRedoGroup);
|
|
550
559
|
break;
|
|
551
|
-
case
|
|
560
|
+
case 9 :
|
|
552
561
|
this._assertIndex(cellIndex);
|
|
553
562
|
this._changeCellInternalMetadataPartial(this._cells[cellIndex], edit.internalMetadata);
|
|
554
563
|
break;
|
|
555
|
-
case
|
|
564
|
+
case 4 :
|
|
556
565
|
this._assertIndex(edit.index);
|
|
557
566
|
this._changeCellLanguage(this._cells[edit.index], edit.language, computeUndoRedo, beginSelectionState, undoRedoGroup);
|
|
558
567
|
break;
|
|
559
|
-
case
|
|
568
|
+
case 5 :
|
|
560
569
|
this._updateNotebookCellMetadata(edit.metadata, computeUndoRedo, beginSelectionState, undoRedoGroup);
|
|
561
570
|
break;
|
|
562
|
-
case
|
|
571
|
+
case 6 :
|
|
563
572
|
this._moveCellToIdx(edit.index, edit.length, edit.newIdx, synchronous, computeUndoRedo, beginSelectionState, undefined, undoRedoGroup);
|
|
564
573
|
break;
|
|
565
574
|
}
|
|
@@ -570,17 +579,17 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
|
|
|
570
579
|
rawEdits.forEach(edit => {
|
|
571
580
|
if (mergedEdits.length) {
|
|
572
581
|
const last = mergedEdits[mergedEdits.length - 1];
|
|
573
|
-
if (last.edit.editType ===
|
|
582
|
+
if (last.edit.editType === 2
|
|
574
583
|
&& last.edit.append
|
|
575
|
-
&& edit.edit.editType ===
|
|
584
|
+
&& edit.edit.editType === 2
|
|
576
585
|
&& edit.edit.append
|
|
577
586
|
&& last.cellIndex === edit.cellIndex) {
|
|
578
587
|
last.edit.outputs = [...last.edit.outputs, ...edit.edit.outputs];
|
|
579
588
|
}
|
|
580
|
-
else if (last.edit.editType ===
|
|
589
|
+
else if (last.edit.editType === 2
|
|
581
590
|
&& !last.edit.append
|
|
582
591
|
&& last.edit.outputs.length === 0
|
|
583
|
-
&& edit.edit.editType ===
|
|
592
|
+
&& edit.edit.editType === 2
|
|
584
593
|
&& edit.edit.append
|
|
585
594
|
&& last.cellIndex === edit.cellIndex) {
|
|
586
595
|
last.edit.append = false;
|
|
@@ -693,7 +702,7 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
|
|
|
693
702
|
const that = this;
|
|
694
703
|
this._operationManager.pushEditOperation(new (class {
|
|
695
704
|
constructor() {
|
|
696
|
-
this.type =
|
|
705
|
+
this.type = 0 ;
|
|
697
706
|
this.label = 'Update Cell Metadata';
|
|
698
707
|
this.code = 'undoredo.textBufferEdit';
|
|
699
708
|
}
|
|
@@ -884,7 +893,7 @@ let NotebookTextModel = NotebookTextModel_1 = class NotebookTextModel extends Di
|
|
|
884
893
|
const that = this;
|
|
885
894
|
this._operationManager.pushEditOperation(new (class {
|
|
886
895
|
constructor() {
|
|
887
|
-
this.type =
|
|
896
|
+
this.type = 0 ;
|
|
888
897
|
this.label = 'Update Cell Language';
|
|
889
898
|
this.code = 'undoredo.textBufferEdit';
|
|
890
899
|
}
|
package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js
CHANGED
|
@@ -46,14 +46,14 @@ let NotebookModelReferenceCollection = class NotebookModelReferenceCollection ex
|
|
|
46
46
|
isDirty(resource) {
|
|
47
47
|
return this._dirtyStates.get(resource) ?? false;
|
|
48
48
|
}
|
|
49
|
-
async createReferencedObject(key,
|
|
49
|
+
async createReferencedObject(key, notebookType, hasAssociatedFilePath, limits, isScratchpad, viewType) {
|
|
50
50
|
this.modelsToDispose.delete(key);
|
|
51
51
|
const uri = ( URI.parse(key));
|
|
52
|
-
const workingCopyTypeId = NotebookWorkingCopyTypeIdentifier.create(viewType);
|
|
52
|
+
const workingCopyTypeId = NotebookWorkingCopyTypeIdentifier.create(notebookType, viewType);
|
|
53
53
|
let workingCopyManager = this._workingCopyManagers.get(workingCopyTypeId);
|
|
54
54
|
if (!workingCopyManager) {
|
|
55
55
|
const factory = ( new NotebookFileWorkingCopyModelFactory(
|
|
56
|
-
|
|
56
|
+
notebookType,
|
|
57
57
|
this._notebookService,
|
|
58
58
|
this._configurationService,
|
|
59
59
|
this._telemetryService,
|
|
@@ -62,15 +62,15 @@ let NotebookModelReferenceCollection = class NotebookModelReferenceCollection ex
|
|
|
62
62
|
workingCopyManager = this._instantiationService.createInstance(FileWorkingCopyManager, workingCopyTypeId, factory, factory);
|
|
63
63
|
this._workingCopyManagers.set(workingCopyTypeId, workingCopyManager);
|
|
64
64
|
}
|
|
65
|
-
const isScratchpadView = isScratchpad || (
|
|
66
|
-
const model = this._instantiationService.createInstance(SimpleNotebookEditorModel, uri, hasAssociatedFilePath,
|
|
65
|
+
const isScratchpadView = isScratchpad || (notebookType === 'interactive' && this._configurationService.getValue(NotebookSetting.InteractiveWindowPromptToSave) !== true);
|
|
66
|
+
const model = this._instantiationService.createInstance(SimpleNotebookEditorModel, uri, hasAssociatedFilePath, notebookType, workingCopyManager, isScratchpadView);
|
|
67
67
|
const result = await model.load({ limits });
|
|
68
68
|
let onDirtyAutoReference;
|
|
69
69
|
this._modelListener.set(result, combinedDisposable(result.onDidSave(() => this._onDidSaveNotebook.fire(result.resource)), result.onDidChangeDirty(() => {
|
|
70
70
|
const isDirty = result.isDirty();
|
|
71
71
|
this._dirtyStates.set(result.resource, isDirty);
|
|
72
72
|
if (isDirty && !onDirtyAutoReference) {
|
|
73
|
-
onDirtyAutoReference = this.acquire(key,
|
|
73
|
+
onDirtyAutoReference = this.acquire(key, notebookType);
|
|
74
74
|
}
|
|
75
75
|
else if (onDirtyAutoReference) {
|
|
76
76
|
onDirtyAutoReference.dispose();
|
|
@@ -201,7 +201,7 @@ let NotebookModelResolverServiceImpl = class NotebookModelResolverServiceImpl {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
const validated = await this.validateResourceViewType(resource, viewType);
|
|
204
|
-
const reference = this._data.acquire(( validated.resource.toString()), validated.viewType, hasAssociatedFilePath, options?.limits, options?.scratchpad);
|
|
204
|
+
const reference = this._data.acquire(( validated.resource.toString()), validated.viewType, hasAssociatedFilePath, options?.limits, options?.scratchpad, options?.viewType);
|
|
205
205
|
try {
|
|
206
206
|
const model = await reference.object;
|
|
207
207
|
return {
|