@codingame/monaco-vscode-notebook-service-override 37.1.0 → 37.2.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/index.js +5 -0
- package/package.json +3 -3
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebook.d.ts +22 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebook.js +210 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocuments.d.ts +24 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocuments.js +138 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocumentsAndEditors.d.ts +29 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocumentsAndEditors.js +194 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookEditors.d.ts +27 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookEditors.js +149 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookKernels.d.ts +49 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookKernels.js +372 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookRenderers.d.ts +10 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookRenderers.js +26 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookSaveParticipant.d.ts +9 -0
- package/vscode/src/vs/workbench/api/browser/mainThreadNotebookSaveParticipant.js +43 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticEditorContrib.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticsActions.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/diagnosticCellStatusBarContrib.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +1 -1
- 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 +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookMulticursor.js +4 -4
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/multicursor/notebookSelectionHighlight.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookInlineVariables.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/editActions.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/sectionActions.js +3 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/variablesActions.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditor.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookMultiDiffEditor.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +5 -5
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibleView.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/outputEditor/notebookOutputEditor.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/outputEditor/notebookOutputEditor.js +6 -6
- package/vscode/src/vs/workbench/contrib/notebook/browser/outputEditor/notebookOutputEditorInput.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/replEditorAccessibleView.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/OutlineEntry.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.js +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.d.ts +1 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +2 -2
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModel.d.ts +87 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModel.js +352 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +1 -1
- package/vscode/src/vs/workbench/contrib/replNotebook/browser/repl.contribution.js +2 -2
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { streamToBuffer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/buffer';
|
|
4
|
+
import { CancellationError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
|
|
5
|
+
import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
6
|
+
import { DisposableStore, Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
7
|
+
import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
|
|
8
|
+
import { hasKey, assertType } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
9
|
+
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
10
|
+
import { FileOperationError, FileOperationResult } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files';
|
|
11
|
+
import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
12
|
+
import { EditorModel } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor/editorModel';
|
|
13
|
+
import { NotebookCellsChangeType, NotebookSetting } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
14
|
+
import { INotebookLoggingService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookLoggingService.service';
|
|
15
|
+
import { SimpleNotebookProviderInfo } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService';
|
|
16
|
+
import { INotebookService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService.service';
|
|
17
|
+
import { IFilesConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService.service';
|
|
18
|
+
import { StoredFileWorkingCopyState } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/workingCopy/common/storedFileWorkingCopy';
|
|
19
|
+
import { WorkingCopyCapabilities } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/workingCopy/common/workingCopy';
|
|
20
|
+
|
|
21
|
+
var SimpleNotebookEditorModel_1;
|
|
22
|
+
let SimpleNotebookEditorModel = SimpleNotebookEditorModel_1 = class SimpleNotebookEditorModel extends EditorModel {
|
|
23
|
+
constructor(
|
|
24
|
+
resource,
|
|
25
|
+
_hasAssociatedFilePath,
|
|
26
|
+
viewType,
|
|
27
|
+
_workingCopyManager,
|
|
28
|
+
scratchpad,
|
|
29
|
+
_filesConfigurationService
|
|
30
|
+
) {
|
|
31
|
+
super();
|
|
32
|
+
this.resource = resource;
|
|
33
|
+
this._hasAssociatedFilePath = _hasAssociatedFilePath;
|
|
34
|
+
this.viewType = viewType;
|
|
35
|
+
this._workingCopyManager = _workingCopyManager;
|
|
36
|
+
this._filesConfigurationService = _filesConfigurationService;
|
|
37
|
+
this._onDidChangeDirty = this._register(( new Emitter()));
|
|
38
|
+
this._onDidSave = this._register(( new Emitter()));
|
|
39
|
+
this._onDidChangeOrphaned = this._register(( new Emitter()));
|
|
40
|
+
this._onDidChangeReadonly = this._register(( new Emitter()));
|
|
41
|
+
this._onDidRevertUntitled = this._register(( new Emitter()));
|
|
42
|
+
this.onDidChangeDirty = this._onDidChangeDirty.event;
|
|
43
|
+
this.onDidSave = this._onDidSave.event;
|
|
44
|
+
this.onDidChangeOrphaned = this._onDidChangeOrphaned.event;
|
|
45
|
+
this.onDidChangeReadonly = this._onDidChangeReadonly.event;
|
|
46
|
+
this.onDidRevertUntitled = this._onDidRevertUntitled.event;
|
|
47
|
+
this._workingCopyListeners = this._register(( new DisposableStore()));
|
|
48
|
+
this.scratchPad = scratchpad;
|
|
49
|
+
}
|
|
50
|
+
dispose() {
|
|
51
|
+
this._workingCopy?.dispose();
|
|
52
|
+
super.dispose();
|
|
53
|
+
}
|
|
54
|
+
get notebook() {
|
|
55
|
+
return this._workingCopy?.model?.notebookModel;
|
|
56
|
+
}
|
|
57
|
+
isResolved() {
|
|
58
|
+
return Boolean(this._workingCopy?.model?.notebookModel);
|
|
59
|
+
}
|
|
60
|
+
async canDispose() {
|
|
61
|
+
if (!this._workingCopy) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
if (SimpleNotebookEditorModel_1._isStoredFileWorkingCopy(this._workingCopy)) {
|
|
65
|
+
return this._workingCopyManager.stored.canDispose(this._workingCopy);
|
|
66
|
+
} else {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
isDirty() {
|
|
71
|
+
return this._workingCopy?.isDirty() ?? false;
|
|
72
|
+
}
|
|
73
|
+
isModified() {
|
|
74
|
+
return this._workingCopy?.isModified() ?? false;
|
|
75
|
+
}
|
|
76
|
+
isOrphaned() {
|
|
77
|
+
return SimpleNotebookEditorModel_1._isStoredFileWorkingCopy(this._workingCopy) && this._workingCopy.hasState(StoredFileWorkingCopyState.ORPHAN);
|
|
78
|
+
}
|
|
79
|
+
hasAssociatedFilePath() {
|
|
80
|
+
return !SimpleNotebookEditorModel_1._isStoredFileWorkingCopy(this._workingCopy) && !!this._workingCopy?.hasAssociatedFilePath;
|
|
81
|
+
}
|
|
82
|
+
isReadonly() {
|
|
83
|
+
if (SimpleNotebookEditorModel_1._isStoredFileWorkingCopy(this._workingCopy)) {
|
|
84
|
+
return this._workingCopy?.isReadonly();
|
|
85
|
+
} else {
|
|
86
|
+
return this._filesConfigurationService.isReadonly(this.resource);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
get hasErrorState() {
|
|
90
|
+
if (this._workingCopy && hasKey(this._workingCopy, {
|
|
91
|
+
hasState: true
|
|
92
|
+
})) {
|
|
93
|
+
return this._workingCopy.hasState(StoredFileWorkingCopyState.ERROR);
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
async revert(options) {
|
|
98
|
+
assertType(this.isResolved());
|
|
99
|
+
return this._workingCopy.revert(options);
|
|
100
|
+
}
|
|
101
|
+
async save(options) {
|
|
102
|
+
assertType(this.isResolved());
|
|
103
|
+
return this._workingCopy.save(options);
|
|
104
|
+
}
|
|
105
|
+
async load(options) {
|
|
106
|
+
if (!this._workingCopy || !this._workingCopy.model) {
|
|
107
|
+
if (this.resource.scheme === Schemas.untitled) {
|
|
108
|
+
if (this._hasAssociatedFilePath) {
|
|
109
|
+
this._workingCopy = await this._workingCopyManager.resolve({
|
|
110
|
+
associatedResource: this.resource
|
|
111
|
+
});
|
|
112
|
+
} else {
|
|
113
|
+
this._workingCopy = await this._workingCopyManager.resolve({
|
|
114
|
+
untitledResource: this.resource,
|
|
115
|
+
isScratchpad: this.scratchPad
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
this._register(this._workingCopy.onDidRevert(() => this._onDidRevertUntitled.fire()));
|
|
119
|
+
} else {
|
|
120
|
+
this._workingCopy = await this._workingCopyManager.resolve(this.resource, {
|
|
121
|
+
limits: options?.limits,
|
|
122
|
+
reload: options?.forceReadFromFile ? {
|
|
123
|
+
async: false,
|
|
124
|
+
force: true
|
|
125
|
+
} : undefined
|
|
126
|
+
});
|
|
127
|
+
this._workingCopyListeners.add(this._workingCopy.onDidSave(e => this._onDidSave.fire(e)));
|
|
128
|
+
this._workingCopyListeners.add(
|
|
129
|
+
this._workingCopy.onDidChangeOrphaned(() => this._onDidChangeOrphaned.fire())
|
|
130
|
+
);
|
|
131
|
+
this._workingCopyListeners.add(
|
|
132
|
+
this._workingCopy.onDidChangeReadonly(() => this._onDidChangeReadonly.fire())
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
this._workingCopyListeners.add(
|
|
136
|
+
this._workingCopy.onDidChangeDirty(() => this._onDidChangeDirty.fire(), undefined)
|
|
137
|
+
);
|
|
138
|
+
this._workingCopyListeners.add(this._workingCopy.onWillDispose(() => {
|
|
139
|
+
this._workingCopyListeners.clear();
|
|
140
|
+
this._workingCopy?.model?.dispose();
|
|
141
|
+
}));
|
|
142
|
+
} else {
|
|
143
|
+
await this._workingCopyManager.resolve(this.resource, {
|
|
144
|
+
reload: {
|
|
145
|
+
async: !options?.forceReadFromFile,
|
|
146
|
+
force: options?.forceReadFromFile
|
|
147
|
+
},
|
|
148
|
+
limits: options?.limits
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
assertType(this.isResolved());
|
|
152
|
+
return this;
|
|
153
|
+
}
|
|
154
|
+
async saveAs(target) {
|
|
155
|
+
const newWorkingCopy = await this._workingCopyManager.saveAs(this.resource, target);
|
|
156
|
+
if (!newWorkingCopy) {
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
resource: newWorkingCopy.resource
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
static _isStoredFileWorkingCopy(candidate) {
|
|
164
|
+
const isUntitled = candidate && candidate.capabilities & WorkingCopyCapabilities.Untitled;
|
|
165
|
+
return !isUntitled;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
SimpleNotebookEditorModel = SimpleNotebookEditorModel_1 = ( __decorate([( __param(5, IFilesConfigurationService))], SimpleNotebookEditorModel));
|
|
169
|
+
class NotebookFileWorkingCopyModel extends Disposable {
|
|
170
|
+
constructor(
|
|
171
|
+
_notebookModel,
|
|
172
|
+
_notebookService,
|
|
173
|
+
_configurationService,
|
|
174
|
+
_telemetryService,
|
|
175
|
+
_notebookLogService
|
|
176
|
+
) {
|
|
177
|
+
super();
|
|
178
|
+
this._notebookModel = _notebookModel;
|
|
179
|
+
this._notebookService = _notebookService;
|
|
180
|
+
this._configurationService = _configurationService;
|
|
181
|
+
this._telemetryService = _telemetryService;
|
|
182
|
+
this._notebookLogService = _notebookLogService;
|
|
183
|
+
this._onDidChangeContent = this._register(( new Emitter()));
|
|
184
|
+
this.onDidChangeContent = this._onDidChangeContent.event;
|
|
185
|
+
this.configuration = undefined;
|
|
186
|
+
this.onWillDispose = _notebookModel.onWillDispose.bind(_notebookModel);
|
|
187
|
+
this._register(_notebookModel.onDidChangeContent(e => {
|
|
188
|
+
for (const rawEvent of e.rawEvents) {
|
|
189
|
+
if (rawEvent.kind === NotebookCellsChangeType.Initialize) {
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if (rawEvent.transient) {
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
this._onDidChangeContent.fire({
|
|
196
|
+
isRedoing: false,
|
|
197
|
+
isUndoing: false,
|
|
198
|
+
isInitial: false
|
|
199
|
+
});
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}));
|
|
203
|
+
const saveWithReducedCommunication = this._configurationService.getValue(NotebookSetting.remoteSaving);
|
|
204
|
+
if (saveWithReducedCommunication || _notebookModel.uri.scheme === Schemas.vscodeRemote) {
|
|
205
|
+
this.configuration = {
|
|
206
|
+
backupDelay: 10000
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
if (saveWithReducedCommunication) {
|
|
210
|
+
this.setSaveDelegate().catch(
|
|
211
|
+
error => this._notebookLogService.error("WorkingCopyModel", `Failed to set save delegate: ${error}`)
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
async setSaveDelegate() {
|
|
216
|
+
await this.getNotebookSerializer();
|
|
217
|
+
this.save = async (options, token) => {
|
|
218
|
+
try {
|
|
219
|
+
let serializer = this._notebookService.tryGetDataProviderSync(this.notebookModel.viewType)?.serializer;
|
|
220
|
+
if (!serializer) {
|
|
221
|
+
this._notebookLogService.info(
|
|
222
|
+
"WorkingCopyModel",
|
|
223
|
+
"No serializer found for notebook model, checking if provider still needs to be resolved"
|
|
224
|
+
);
|
|
225
|
+
serializer = await this.getNotebookSerializer().catch(error => {
|
|
226
|
+
this._notebookLogService.error("WorkingCopyModel", `Failed to get notebook serializer: ${error}`);
|
|
227
|
+
this.save = undefined;
|
|
228
|
+
throw ( new NotebookSaveError("Failed to get notebook serializer"));
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
if (token.isCancellationRequested) {
|
|
232
|
+
throw ( new CancellationError());
|
|
233
|
+
}
|
|
234
|
+
const stat = await serializer.save(this._notebookModel.uri, this._notebookModel.versionId, options, token);
|
|
235
|
+
return stat;
|
|
236
|
+
} catch (error) {
|
|
237
|
+
if (!token.isCancellationRequested && error.name !== "Canceled") {
|
|
238
|
+
const isIPynb = this._notebookModel.viewType === "jupyter-notebook" || this._notebookModel.viewType === "interactive";
|
|
239
|
+
const errorMessage = getSaveErrorMessage(error);
|
|
240
|
+
this._telemetryService.publicLogError2("notebook/SaveError", {
|
|
241
|
+
isRemote: this._notebookModel.uri.scheme === Schemas.vscodeRemote,
|
|
242
|
+
isIPyNbWorkerSerializer: isIPynb && this._configurationService.getValue("ipynb.experimental.serialization"),
|
|
243
|
+
error: errorMessage
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
throw error;
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
dispose() {
|
|
251
|
+
this._notebookModel.dispose();
|
|
252
|
+
super.dispose();
|
|
253
|
+
}
|
|
254
|
+
get notebookModel() {
|
|
255
|
+
return this._notebookModel;
|
|
256
|
+
}
|
|
257
|
+
async snapshot(context, token) {
|
|
258
|
+
return this._notebookService.createNotebookTextDocumentSnapshot(this._notebookModel.uri, context, token);
|
|
259
|
+
}
|
|
260
|
+
async update(stream, token) {
|
|
261
|
+
const serializer = await this.getNotebookSerializer();
|
|
262
|
+
const bytes = await streamToBuffer(stream);
|
|
263
|
+
const data = await serializer.dataToNotebook(bytes);
|
|
264
|
+
if (token.isCancellationRequested) {
|
|
265
|
+
throw ( new CancellationError());
|
|
266
|
+
}
|
|
267
|
+
this._notebookLogService.info(
|
|
268
|
+
"WorkingCopyModel",
|
|
269
|
+
"Notebook content updated from file system - " + ( this._notebookModel.uri.toString())
|
|
270
|
+
);
|
|
271
|
+
this._notebookModel.reset(data.cells, data.metadata, serializer.options);
|
|
272
|
+
}
|
|
273
|
+
async getNotebookSerializer() {
|
|
274
|
+
const info = await this._notebookService.withNotebookDataProvider(this.notebookModel.viewType);
|
|
275
|
+
if (!(info instanceof SimpleNotebookProviderInfo)) {
|
|
276
|
+
const message = "CANNOT open notebook with this provider";
|
|
277
|
+
throw ( new NotebookSaveError(message));
|
|
278
|
+
}
|
|
279
|
+
return info.serializer;
|
|
280
|
+
}
|
|
281
|
+
get versionId() {
|
|
282
|
+
return this._notebookModel.alternativeVersionId;
|
|
283
|
+
}
|
|
284
|
+
pushStackElement() {
|
|
285
|
+
this._notebookModel.pushStackElement();
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
let NotebookFileWorkingCopyModelFactory = class NotebookFileWorkingCopyModelFactory {
|
|
289
|
+
constructor(
|
|
290
|
+
_viewType,
|
|
291
|
+
_notebookService,
|
|
292
|
+
_configurationService,
|
|
293
|
+
_telemetryService,
|
|
294
|
+
_notebookLogService
|
|
295
|
+
) {
|
|
296
|
+
this._viewType = _viewType;
|
|
297
|
+
this._notebookService = _notebookService;
|
|
298
|
+
this._configurationService = _configurationService;
|
|
299
|
+
this._telemetryService = _telemetryService;
|
|
300
|
+
this._notebookLogService = _notebookLogService;
|
|
301
|
+
}
|
|
302
|
+
async createModel(resource, stream, token) {
|
|
303
|
+
const notebookModel = this._notebookService.getNotebookTextModel(resource) ?? (await this._notebookService.createNotebookTextModel(this._viewType, resource, stream));
|
|
304
|
+
return ( new NotebookFileWorkingCopyModel(
|
|
305
|
+
notebookModel,
|
|
306
|
+
this._notebookService,
|
|
307
|
+
this._configurationService,
|
|
308
|
+
this._telemetryService,
|
|
309
|
+
this._notebookLogService
|
|
310
|
+
));
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
NotebookFileWorkingCopyModelFactory = ( __decorate([( __param(1, INotebookService)), ( __param(2, IConfigurationService)), ( __param(3, ITelemetryService)), ( __param(4, INotebookLoggingService))], NotebookFileWorkingCopyModelFactory));
|
|
314
|
+
class NotebookSaveError extends Error {
|
|
315
|
+
constructor(message) {
|
|
316
|
+
super(message);
|
|
317
|
+
this.name = "NotebookSaveError";
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
function getSaveErrorMessage(error) {
|
|
321
|
+
if (error.name === "NotebookSaveError") {
|
|
322
|
+
return error.message;
|
|
323
|
+
} else if (error instanceof FileOperationError) {
|
|
324
|
+
switch (error.fileOperationResult) {
|
|
325
|
+
case FileOperationResult.FILE_IS_DIRECTORY:
|
|
326
|
+
return "File is a directory";
|
|
327
|
+
case FileOperationResult.FILE_NOT_FOUND:
|
|
328
|
+
return "File not found";
|
|
329
|
+
case FileOperationResult.FILE_NOT_MODIFIED_SINCE:
|
|
330
|
+
return "File not modified since";
|
|
331
|
+
case FileOperationResult.FILE_MODIFIED_SINCE:
|
|
332
|
+
return "File modified since";
|
|
333
|
+
case FileOperationResult.FILE_MOVE_CONFLICT:
|
|
334
|
+
return "File move conflict";
|
|
335
|
+
case FileOperationResult.FILE_WRITE_LOCKED:
|
|
336
|
+
return "File write locked";
|
|
337
|
+
case FileOperationResult.FILE_PERMISSION_DENIED:
|
|
338
|
+
return "File permission denied";
|
|
339
|
+
case FileOperationResult.FILE_TOO_LARGE:
|
|
340
|
+
return "File too large";
|
|
341
|
+
case FileOperationResult.FILE_INVALID_PATH:
|
|
342
|
+
return "File invalid path";
|
|
343
|
+
case FileOperationResult.FILE_NOT_DIRECTORY:
|
|
344
|
+
return "File not directory";
|
|
345
|
+
case FileOperationResult.FILE_OTHER_ERROR:
|
|
346
|
+
return "File other error";
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return "Unknown error";
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export { NotebookFileWorkingCopyModel, NotebookFileWorkingCopyModelFactory, SimpleNotebookEditorModel };
|
package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js
CHANGED
|
@@ -3,7 +3,7 @@ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib
|
|
|
3
3
|
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
4
4
|
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
5
5
|
import { NotebookWorkingCopyTypeIdentifier, NotebookSetting, CellUri } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|
|
6
|
-
import { NotebookFileWorkingCopyModelFactory, SimpleNotebookEditorModel } from '
|
|
6
|
+
import { NotebookFileWorkingCopyModelFactory, SimpleNotebookEditorModel } from './notebookEditorModel.js';
|
|
7
7
|
import { ReferenceCollection, DisposableStore, dispose, combinedDisposable, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
8
8
|
import { INotebookService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookService.service';
|
|
9
9
|
import { Emitter, AsyncEmitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
@@ -35,8 +35,8 @@ import { getReplView } from '@codingame/monaco-vscode-api/vscode/vs/workbench/co
|
|
|
35
35
|
import { REPL_VIEW_ID } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/debug/common/debug';
|
|
36
36
|
import { InlineChatController } from '@codingame/monaco-vscode-katex-common/vscode/vs/workbench/contrib/inlineChat/browser/inlineChatController';
|
|
37
37
|
import { IInteractiveHistoryService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/interactive/browser/interactiveHistoryService.service';
|
|
38
|
-
import { NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT } from '@codingame/monaco-vscode-
|
|
39
|
-
import { executeIcon } from '@codingame/monaco-vscode-
|
|
38
|
+
import { NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT } from '@codingame/monaco-vscode-katex-common/vscode/vs/workbench/contrib/notebook/browser/controller/coreActions';
|
|
39
|
+
import { executeIcon } from '@codingame/monaco-vscode-katex-common/vscode/vs/workbench/contrib/notebook/browser/notebookIcons';
|
|
40
40
|
import { ReplEditorAccessibleView } from '../../notebook/browser/replEditorAccessibleView.js';
|
|
41
41
|
import { INotebookEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/browser/services/notebookEditorService.service';
|
|
42
42
|
import { REPL_EDITOR_ID, NotebookSetting, NotebookWorkingCopyTypeIdentifier, CellKind, CellEditType } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/notebook/common/notebookCommon';
|