@codingame/monaco-vscode-notebook-service-override 3.2.3 → 4.1.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 (80) hide show
  1. package/notebook.js +13 -13
  2. package/package.json +2 -2
  3. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +0 -3
  4. package/external/tslib/tslib.es6.js +0 -11
  5. package/override/vs/platform/dialogs/common/dialogs.js +0 -8
  6. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.css.js +0 -6
  7. package/vscode/src/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js +0 -389
  8. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellCommands/cellCommands.js +0 -608
  9. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/contributedStatusBarItemController.js +0 -109
  10. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/cellStatusBar/statusBarProviders.js +0 -173
  11. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/notebookClipboard.js +0 -488
  12. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookBreakpoints.js +0 -106
  13. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookCellPausing.js +0 -67
  14. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/debug/notebookDebugDecorations.js +0 -165
  15. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js +0 -67
  16. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/editorStatusBar/editorStatusBar.js +0 -320
  17. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/execute/executionEditorProgress.js +0 -72
  18. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/media/notebookFind.css.js +0 -6
  19. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFind.js +0 -168
  20. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.js +0 -209
  21. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/gettingStarted/notebookGettingStarted.js +0 -84
  22. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/kernelDetection/notebookKernelDetection.js +0 -82
  23. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/layout/layoutActions.js +0 -67
  24. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider.js +0 -91
  25. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/navigation/arrow.js +0 -393
  26. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariableContextKeys.js +0 -5
  27. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariables.js +0 -97
  28. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesDataSource.js +0 -118
  29. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesTree.js +0 -59
  30. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesView.js +0 -148
  31. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.js +0 -383
  32. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/profile/notebookProfile.js +0 -77
  33. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/saveParticipants/saveParticipants.js +0 -511
  34. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/troubleshoot/layout.js +0 -159
  35. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/undoRedo/notebookUndoRedo.js +0 -56
  36. package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/viewportWarmup/viewportWarmup.js +0 -94
  37. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/apiActions.js +0 -51
  38. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/cellChatActions.js +0 -565
  39. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatContext.js +0 -31
  40. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/chat/notebookChatController.js +0 -744
  41. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/executeActions.js +0 -707
  42. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +0 -351
  43. package/vscode/src/vs/workbench/contrib/notebook/browser/controller/layoutActions.js +0 -267
  44. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffCellEditorOptions.js +0 -45
  45. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffComponents.js +0 -1297
  46. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementOutputs.js +0 -284
  47. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffElementViewModel.js +0 -563
  48. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/diffNestedCellViewModel.js +0 -108
  49. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.js +0 -39
  50. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiff.css.js +0 -6
  51. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffActions.js +0 -313
  52. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditor.js +0 -890
  53. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser.js +0 -13
  54. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffList.js +0 -393
  55. package/vscode/src/vs/workbench/contrib/notebook/browser/diff/notebookDiffOverviewRuler.js +0 -175
  56. package/vscode/src/vs/workbench/contrib/notebook/browser/notebook.contribution.js +0 -1174
  57. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookAccessibility.js +0 -159
  58. package/vscode/src/vs/workbench/contrib/notebook/browser/notebookExtensionPoint.js +0 -451
  59. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookEditorServiceImpl.js +0 -192
  60. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionServiceImpl.js +0 -106
  61. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookExecutionStateServiceImpl.js +0 -509
  62. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelHistoryServiceImpl.js +0 -130
  63. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKernelServiceImpl.js +0 -341
  64. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookKeymapServiceImpl.js +0 -111
  65. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookLoggingServiceImpl.js +0 -28
  66. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookRendererMessagingServiceImpl.js +0 -65
  67. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.js +0 -641
  68. package/vscode/src/vs/workbench/contrib/notebook/browser/services/notebookWorkerServiceImpl.js +0 -200
  69. package/vscode/src/vs/workbench/contrib/notebook/common/model/cellEdit.js +0 -80
  70. package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookTextModel.js +0 -1003
  71. package/vscode/src/vs/workbench/contrib/notebook/common/notebookDiffEditorInput.js +0 -103
  72. package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModelResolverServiceImpl.js +0 -202
  73. package/vscode/src/vs/workbench/contrib/notebook/common/notebookOutputRenderer.js +0 -80
  74. package/vscode/src/vs/workbench/contrib/notebook/common/notebookProvider.js +0 -98
  75. package/vscode/src/vs/workbench/contrib/search/browser/notebookSearch/notebookSearchService.js +0 -237
  76. package/vscode/src/vs/workbench/services/workingCopy/common/abstractFileWorkingCopyManager.js +0 -89
  77. package/vscode/src/vs/workbench/services/workingCopy/common/fileWorkingCopyManager.js +0 -376
  78. package/vscode/src/vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager.js +0 -408
  79. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.js +0 -144
  80. package/vscode/src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.js +0 -129
@@ -1,408 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
3
- import { DisposableStore, dispose } from 'vscode/vscode/vs/base/common/lifecycle';
4
- import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
5
- import { StoredFileWorkingCopy } from 'vscode/vscode/vs/workbench/services/workingCopy/common/storedFileWorkingCopy';
6
- import { ResourceMap } from 'vscode/vscode/vs/base/common/map';
7
- import { ResourceQueue, Promises } from 'vscode/vscode/vs/base/common/async';
8
- import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
9
- import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
10
- import { URI } from 'vscode/vscode/vs/base/common/uri';
11
- import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label';
12
- import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
13
- import { joinPath } from 'vscode/vscode/vs/base/common/resources';
14
- import { IWorkingCopyFileService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyFileService';
15
- import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
16
- import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
17
- import { IWorkingCopyBackupService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyBackup';
18
- import { BaseFileWorkingCopyManager } from './abstractFileWorkingCopyManager.js';
19
- import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
20
- import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
21
- import { IElevatedFileService } from 'vscode/vscode/vs/workbench/services/files/common/elevatedFileService';
22
- import { IFilesConfigurationService } from 'vscode/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService';
23
- import { IWorkingCopyEditorService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyEditorService';
24
- import { IWorkingCopyService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyService';
25
- import { isWeb } from 'vscode/vscode/vs/base/common/platform';
26
- import { onUnexpectedError } from 'vscode/vscode/vs/base/common/errors';
27
-
28
- let StoredFileWorkingCopyManager = class StoredFileWorkingCopyManager extends BaseFileWorkingCopyManager {
29
- constructor(workingCopyTypeId, modelFactory, fileService, lifecycleService, labelService, logService, workingCopyFileService, workingCopyBackupService, uriIdentityService, filesConfigurationService, workingCopyService, notificationService, workingCopyEditorService, editorService, elevatedFileService) {
30
- super(fileService, logService, workingCopyBackupService);
31
- this.workingCopyTypeId = workingCopyTypeId;
32
- this.modelFactory = modelFactory;
33
- this.lifecycleService = lifecycleService;
34
- this.labelService = labelService;
35
- this.workingCopyFileService = workingCopyFileService;
36
- this.uriIdentityService = uriIdentityService;
37
- this.filesConfigurationService = filesConfigurationService;
38
- this.workingCopyService = workingCopyService;
39
- this.notificationService = notificationService;
40
- this.workingCopyEditorService = workingCopyEditorService;
41
- this.editorService = editorService;
42
- this.elevatedFileService = elevatedFileService;
43
- this._onDidResolve = this._register(( new Emitter()));
44
- this.onDidResolve = this._onDidResolve.event;
45
- this._onDidChangeDirty = this._register(( new Emitter()));
46
- this.onDidChangeDirty = this._onDidChangeDirty.event;
47
- this._onDidChangeReadonly = this._register(( new Emitter()));
48
- this.onDidChangeReadonly = this._onDidChangeReadonly.event;
49
- this._onDidChangeOrphaned = this._register(( new Emitter()));
50
- this.onDidChangeOrphaned = this._onDidChangeOrphaned.event;
51
- this._onDidSaveError = this._register(( new Emitter()));
52
- this.onDidSaveError = this._onDidSaveError.event;
53
- this._onDidSave = this._register(( new Emitter()));
54
- this.onDidSave = this._onDidSave.event;
55
- this._onDidRevert = this._register(( new Emitter()));
56
- this.onDidRevert = this._onDidRevert.event;
57
- this._onDidRemove = this._register(( new Emitter()));
58
- this.onDidRemove = this._onDidRemove.event;
59
- this.mapResourceToWorkingCopyListeners = ( new ResourceMap());
60
- this.mapResourceToPendingWorkingCopyResolve = ( new ResourceMap());
61
- this.workingCopyResolveQueue = this._register(( new ResourceQueue()));
62
- this.mapCorrelationIdToWorkingCopiesToRestore = ( new Map());
63
- this.registerListeners();
64
- }
65
- registerListeners() {
66
- this._register(this.fileService.onDidFilesChange(e => this.onDidFilesChange(e)));
67
- this._register(this.fileService.onDidChangeFileSystemProviderCapabilities(e => this.onDidChangeFileSystemProviderCapabilities(e)));
68
- this._register(this.fileService.onDidChangeFileSystemProviderRegistrations(e => this.onDidChangeFileSystemProviderRegistrations(e)));
69
- this._register(this.workingCopyFileService.onWillRunWorkingCopyFileOperation(e => this.onWillRunWorkingCopyFileOperation(e)));
70
- this._register(this.workingCopyFileService.onDidFailWorkingCopyFileOperation(e => this.onDidFailWorkingCopyFileOperation(e)));
71
- this._register(this.workingCopyFileService.onDidRunWorkingCopyFileOperation(e => this.onDidRunWorkingCopyFileOperation(e)));
72
- if (isWeb) {
73
- this._register(this.lifecycleService.onBeforeShutdown(event => event.veto(this.onBeforeShutdownWeb(), 'veto.fileWorkingCopyManager')));
74
- }
75
- else {
76
- this._register(this.lifecycleService.onWillShutdown(event => event.join(this.onWillShutdownDesktop(), { id: 'join.fileWorkingCopyManager', label: ( localizeWithPath(
77
- 'vs/workbench/services/workingCopy/common/storedFileWorkingCopyManager',
78
- 'join.fileWorkingCopyManager',
79
- "Saving working copies"
80
- )) })));
81
- }
82
- }
83
- onBeforeShutdownWeb() {
84
- if (( this.workingCopies.some(
85
- workingCopy => workingCopy.hasState(2 )
86
- ))) {
87
- return true;
88
- }
89
- return false;
90
- }
91
- async onWillShutdownDesktop() {
92
- let pendingSavedWorkingCopies;
93
- while ((pendingSavedWorkingCopies = this.workingCopies.filter(workingCopy => workingCopy.hasState(2 ))).length > 0) {
94
- await Promises.settled(( pendingSavedWorkingCopies.map(
95
- workingCopy => workingCopy.joinState(2 )
96
- )));
97
- }
98
- }
99
- onDidChangeFileSystemProviderCapabilities(e) {
100
- this.queueWorkingCopyReloads(e.scheme);
101
- }
102
- onDidChangeFileSystemProviderRegistrations(e) {
103
- if (!e.added) {
104
- return;
105
- }
106
- this.queueWorkingCopyReloads(e.scheme);
107
- }
108
- onDidFilesChange(e) {
109
- this.queueWorkingCopyReloads(e);
110
- }
111
- queueWorkingCopyReloads(schemeOrEvent) {
112
- for (const workingCopy of this.workingCopies) {
113
- if (workingCopy.isDirty()) {
114
- continue;
115
- }
116
- let resolveWorkingCopy = false;
117
- if (typeof schemeOrEvent === 'string') {
118
- resolveWorkingCopy = schemeOrEvent === workingCopy.resource.scheme;
119
- }
120
- else {
121
- resolveWorkingCopy = schemeOrEvent.contains(workingCopy.resource, 0 , 1 );
122
- }
123
- if (resolveWorkingCopy) {
124
- this.queueWorkingCopyReload(workingCopy);
125
- }
126
- }
127
- }
128
- queueWorkingCopyReload(workingCopy) {
129
- const queueSize = this.workingCopyResolveQueue.queueSize(workingCopy.resource);
130
- if (queueSize <= 1) {
131
- this.workingCopyResolveQueue.queueFor(workingCopy.resource, async () => {
132
- try {
133
- await this.reload(workingCopy);
134
- }
135
- catch (error) {
136
- this.logService.error(error);
137
- }
138
- });
139
- }
140
- }
141
- onWillRunWorkingCopyFileOperation(e) {
142
- if (e.operation === 2 || e.operation === 3 ) {
143
- e.waitUntil((async () => {
144
- const workingCopiesToRestore = [];
145
- for (const { source, target } of e.files) {
146
- if (source) {
147
- if (this.uriIdentityService.extUri.isEqual(source, target)) {
148
- continue;
149
- }
150
- const sourceWorkingCopies = [];
151
- for (const workingCopy of this.workingCopies) {
152
- if (this.uriIdentityService.extUri.isEqualOrParent(workingCopy.resource, source)) {
153
- sourceWorkingCopies.push(workingCopy);
154
- }
155
- }
156
- for (const sourceWorkingCopy of sourceWorkingCopies) {
157
- const sourceResource = sourceWorkingCopy.resource;
158
- let targetResource;
159
- if (this.uriIdentityService.extUri.isEqual(sourceResource, source)) {
160
- targetResource = target;
161
- }
162
- else {
163
- targetResource = joinPath(target, sourceResource.path.substr(source.path.length + 1));
164
- }
165
- workingCopiesToRestore.push({
166
- source: sourceResource,
167
- target: targetResource,
168
- snapshot: sourceWorkingCopy.isDirty() ? await sourceWorkingCopy.model?.snapshot(CancellationToken.None) : undefined
169
- });
170
- }
171
- }
172
- }
173
- this.mapCorrelationIdToWorkingCopiesToRestore.set(e.correlationId, workingCopiesToRestore);
174
- })());
175
- }
176
- }
177
- onDidFailWorkingCopyFileOperation(e) {
178
- if (((e.operation === 2 || e.operation === 3) )) {
179
- const workingCopiesToRestore = this.mapCorrelationIdToWorkingCopiesToRestore.get(e.correlationId);
180
- if (workingCopiesToRestore) {
181
- this.mapCorrelationIdToWorkingCopiesToRestore.delete(e.correlationId);
182
- for (const workingCopy of workingCopiesToRestore) {
183
- if (workingCopy.snapshot) {
184
- this.get(workingCopy.source)?.markModified();
185
- }
186
- }
187
- }
188
- }
189
- }
190
- onDidRunWorkingCopyFileOperation(e) {
191
- switch (e.operation) {
192
- case 0 :
193
- e.waitUntil((async () => {
194
- for (const { target } of e.files) {
195
- const workingCopy = this.get(target);
196
- if (workingCopy && !workingCopy.isDisposed()) {
197
- await workingCopy.revert();
198
- }
199
- }
200
- })());
201
- break;
202
- case 2 :
203
- case 3 :
204
- e.waitUntil((async () => {
205
- const workingCopiesToRestore = this.mapCorrelationIdToWorkingCopiesToRestore.get(e.correlationId);
206
- if (workingCopiesToRestore) {
207
- this.mapCorrelationIdToWorkingCopiesToRestore.delete(e.correlationId);
208
- await Promises.settled(( workingCopiesToRestore.map(async (workingCopyToRestore) => {
209
- await this.resolve(workingCopyToRestore.target, {
210
- reload: { async: false },
211
- contents: workingCopyToRestore.snapshot
212
- });
213
- })));
214
- }
215
- })());
216
- break;
217
- }
218
- }
219
- async reload(workingCopy) {
220
- await this.joinPendingResolves(workingCopy.resource);
221
- if (workingCopy.isDirty() || workingCopy.isDisposed() || !( this.has(workingCopy.resource))) {
222
- return;
223
- }
224
- await this.doResolve(workingCopy, { reload: { async: false } });
225
- }
226
- async resolve(resource, options) {
227
- const pendingResolve = this.joinPendingResolves(resource);
228
- if (pendingResolve) {
229
- await pendingResolve;
230
- }
231
- return this.doResolve(resource, options);
232
- }
233
- async doResolve(resourceOrWorkingCopy, options) {
234
- let workingCopy;
235
- let resource;
236
- if (URI.isUri(resourceOrWorkingCopy)) {
237
- resource = resourceOrWorkingCopy;
238
- workingCopy = this.get(resource);
239
- }
240
- else {
241
- resource = resourceOrWorkingCopy.resource;
242
- workingCopy = resourceOrWorkingCopy;
243
- }
244
- let workingCopyResolve;
245
- let didCreateWorkingCopy = false;
246
- const resolveOptions = {
247
- contents: options?.contents,
248
- forceReadFromFile: options?.reload?.force,
249
- limits: options?.limits
250
- };
251
- if (workingCopy) {
252
- if (options?.contents) {
253
- workingCopyResolve = workingCopy.resolve(resolveOptions);
254
- }
255
- else if (options?.reload) {
256
- if (options.reload.async) {
257
- workingCopyResolve = Promise.resolve();
258
- (async () => {
259
- try {
260
- await workingCopy.resolve(resolveOptions);
261
- }
262
- catch (error) {
263
- onUnexpectedError(error);
264
- }
265
- })();
266
- }
267
- else {
268
- workingCopyResolve = workingCopy.resolve(resolveOptions);
269
- }
270
- }
271
- else {
272
- workingCopyResolve = Promise.resolve();
273
- }
274
- }
275
- else {
276
- didCreateWorkingCopy = true;
277
- workingCopy = ( new StoredFileWorkingCopy(
278
- this.workingCopyTypeId,
279
- resource,
280
- this.labelService.getUriBasenameLabel(resource),
281
- this.modelFactory,
282
- async (options) => { await this.resolve(resource, { ...options, reload: { async: false } }); },
283
- this.fileService,
284
- this.logService,
285
- this.workingCopyFileService,
286
- this.filesConfigurationService,
287
- this.workingCopyBackupService,
288
- this.workingCopyService,
289
- this.notificationService,
290
- this.workingCopyEditorService,
291
- this.editorService,
292
- this.elevatedFileService
293
- ));
294
- workingCopyResolve = workingCopy.resolve(resolveOptions);
295
- this.registerWorkingCopy(workingCopy);
296
- }
297
- this.mapResourceToPendingWorkingCopyResolve.set(resource, workingCopyResolve);
298
- this.add(resource, workingCopy);
299
- if (didCreateWorkingCopy) {
300
- if (workingCopy.isDirty()) {
301
- this._onDidChangeDirty.fire(workingCopy);
302
- }
303
- }
304
- try {
305
- await workingCopyResolve;
306
- }
307
- catch (error) {
308
- if (didCreateWorkingCopy) {
309
- workingCopy.dispose();
310
- }
311
- throw error;
312
- }
313
- finally {
314
- this.mapResourceToPendingWorkingCopyResolve.delete(resource);
315
- }
316
- if (didCreateWorkingCopy && workingCopy.isDirty()) {
317
- this._onDidChangeDirty.fire(workingCopy);
318
- }
319
- return workingCopy;
320
- }
321
- joinPendingResolves(resource) {
322
- const pendingWorkingCopyResolve = this.mapResourceToPendingWorkingCopyResolve.get(resource);
323
- if (!pendingWorkingCopyResolve) {
324
- return;
325
- }
326
- return this.doJoinPendingResolves(resource);
327
- }
328
- async doJoinPendingResolves(resource) {
329
- let currentWorkingCopyResolve;
330
- while (( this.mapResourceToPendingWorkingCopyResolve.has(resource))) {
331
- const nextPendingWorkingCopyResolve = this.mapResourceToPendingWorkingCopyResolve.get(resource);
332
- if (nextPendingWorkingCopyResolve === currentWorkingCopyResolve) {
333
- return;
334
- }
335
- currentWorkingCopyResolve = nextPendingWorkingCopyResolve;
336
- try {
337
- await nextPendingWorkingCopyResolve;
338
- }
339
- catch (error) {
340
- }
341
- }
342
- }
343
- registerWorkingCopy(workingCopy) {
344
- const workingCopyListeners = ( new DisposableStore());
345
- workingCopyListeners.add(workingCopy.onDidResolve(() => this._onDidResolve.fire(workingCopy)));
346
- workingCopyListeners.add(workingCopy.onDidChangeDirty(() => this._onDidChangeDirty.fire(workingCopy)));
347
- workingCopyListeners.add(workingCopy.onDidChangeReadonly(() => this._onDidChangeReadonly.fire(workingCopy)));
348
- workingCopyListeners.add(workingCopy.onDidChangeOrphaned(() => this._onDidChangeOrphaned.fire(workingCopy)));
349
- workingCopyListeners.add(workingCopy.onDidSaveError(() => this._onDidSaveError.fire(workingCopy)));
350
- workingCopyListeners.add(workingCopy.onDidSave(e => this._onDidSave.fire({ workingCopy, ...e })));
351
- workingCopyListeners.add(workingCopy.onDidRevert(() => this._onDidRevert.fire(workingCopy)));
352
- this.mapResourceToWorkingCopyListeners.set(workingCopy.resource, workingCopyListeners);
353
- }
354
- remove(resource) {
355
- const removed = super.remove(resource);
356
- const workingCopyListener = this.mapResourceToWorkingCopyListeners.get(resource);
357
- if (workingCopyListener) {
358
- dispose(workingCopyListener);
359
- this.mapResourceToWorkingCopyListeners.delete(resource);
360
- }
361
- if (removed) {
362
- this._onDidRemove.fire(resource);
363
- }
364
- return removed;
365
- }
366
- canDispose(workingCopy) {
367
- if (workingCopy.isDisposed() ||
368
- (!( this.mapResourceToPendingWorkingCopyResolve.has(workingCopy.resource)) && !workingCopy.isDirty())) {
369
- return true;
370
- }
371
- return this.doCanDispose(workingCopy);
372
- }
373
- async doCanDispose(workingCopy) {
374
- const pendingResolve = this.joinPendingResolves(workingCopy.resource);
375
- if (pendingResolve) {
376
- await pendingResolve;
377
- return this.canDispose(workingCopy);
378
- }
379
- if (workingCopy.isDirty()) {
380
- await Event.toPromise(workingCopy.onDidChangeDirty);
381
- return this.canDispose(workingCopy);
382
- }
383
- return true;
384
- }
385
- dispose() {
386
- super.dispose();
387
- this.mapResourceToPendingWorkingCopyResolve.clear();
388
- dispose(( this.mapResourceToWorkingCopyListeners.values()));
389
- this.mapResourceToWorkingCopyListeners.clear();
390
- }
391
- };
392
- StoredFileWorkingCopyManager = ( __decorate([
393
- ( __param(2, IFileService)),
394
- ( __param(3, ILifecycleService)),
395
- ( __param(4, ILabelService)),
396
- ( __param(5, ILogService)),
397
- ( __param(6, IWorkingCopyFileService)),
398
- ( __param(7, IWorkingCopyBackupService)),
399
- ( __param(8, IUriIdentityService)),
400
- ( __param(9, IFilesConfigurationService)),
401
- ( __param(10, IWorkingCopyService)),
402
- ( __param(11, INotificationService)),
403
- ( __param(12, IWorkingCopyEditorService)),
404
- ( __param(13, IEditorService)),
405
- ( __param(14, IElevatedFileService))
406
- ], StoredFileWorkingCopyManager));
407
-
408
- export { StoredFileWorkingCopyManager };
@@ -1,144 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { Emitter } from 'vscode/vscode/vs/base/common/event';
3
- import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
4
- import { IWorkingCopyService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyService';
5
- import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
6
- import { raceCancellation } from 'vscode/vscode/vs/base/common/async';
7
- import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
8
- import { IWorkingCopyBackupService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyBackup';
9
- import { emptyStream } from 'vscode/vscode/vs/base/common/stream';
10
-
11
- let UntitledFileWorkingCopy = class UntitledFileWorkingCopy extends Disposable {
12
- get model() { return this._model; }
13
- constructor(typeId, resource, name, hasAssociatedFilePath, isScratchpad, initialContents, modelFactory, saveDelegate, workingCopyService, workingCopyBackupService, logService) {
14
- super();
15
- this.typeId = typeId;
16
- this.resource = resource;
17
- this.name = name;
18
- this.hasAssociatedFilePath = hasAssociatedFilePath;
19
- this.isScratchpad = isScratchpad;
20
- this.initialContents = initialContents;
21
- this.modelFactory = modelFactory;
22
- this.saveDelegate = saveDelegate;
23
- this.workingCopyBackupService = workingCopyBackupService;
24
- this.logService = logService;
25
- this.capabilities = this.isScratchpad ? 2 | 4 : 2 ;
26
- this._model = undefined;
27
- this._onDidChangeContent = this._register(( new Emitter()));
28
- this.onDidChangeContent = this._onDidChangeContent.event;
29
- this._onDidChangeDirty = this._register(( new Emitter()));
30
- this.onDidChangeDirty = this._onDidChangeDirty.event;
31
- this._onDidSave = this._register(( new Emitter()));
32
- this.onDidSave = this._onDidSave.event;
33
- this._onDidRevert = this._register(( new Emitter()));
34
- this.onDidRevert = this._onDidRevert.event;
35
- this._onWillDispose = this._register(( new Emitter()));
36
- this.onWillDispose = this._onWillDispose.event;
37
- this.modified = this.hasAssociatedFilePath || Boolean(this.initialContents && this.initialContents.markModified !== false);
38
- this._register(workingCopyService.registerWorkingCopy(this));
39
- }
40
- isDirty() {
41
- return this.modified && !this.isScratchpad;
42
- }
43
- isModified() {
44
- return this.modified;
45
- }
46
- setModified(modified) {
47
- if (this.modified === modified) {
48
- return;
49
- }
50
- this.modified = modified;
51
- if (!this.isScratchpad) {
52
- this._onDidChangeDirty.fire();
53
- }
54
- }
55
- async resolve() {
56
- this.trace('resolve()');
57
- if (this.isResolved()) {
58
- this.trace('resolve() - exit (already resolved)');
59
- return;
60
- }
61
- let untitledContents;
62
- const backup = await this.workingCopyBackupService.resolve(this);
63
- if (backup) {
64
- this.trace('resolve() - with backup');
65
- untitledContents = backup.value;
66
- }
67
- else if (this.initialContents?.value) {
68
- this.trace('resolve() - with initial contents');
69
- untitledContents = this.initialContents.value;
70
- }
71
- else {
72
- this.trace('resolve() - empty');
73
- untitledContents = emptyStream();
74
- }
75
- await this.doCreateModel(untitledContents);
76
- this.setModified(this.hasAssociatedFilePath || !!backup || Boolean(this.initialContents && this.initialContents.markModified !== false));
77
- if (!!backup || this.initialContents) {
78
- this._onDidChangeContent.fire();
79
- }
80
- }
81
- async doCreateModel(contents) {
82
- this.trace('doCreateModel()');
83
- this._model = this._register(await this.modelFactory.createModel(this.resource, contents, CancellationToken.None));
84
- this.installModelListeners(this._model);
85
- }
86
- installModelListeners(model) {
87
- this._register(model.onDidChangeContent(e => this.onModelContentChanged(e)));
88
- this._register(model.onWillDispose(() => this.dispose()));
89
- }
90
- onModelContentChanged(e) {
91
- if (!this.hasAssociatedFilePath && e.isInitial) {
92
- this.setModified(false);
93
- }
94
- else {
95
- this.setModified(true);
96
- }
97
- this._onDidChangeContent.fire();
98
- }
99
- isResolved() {
100
- return !!this.model;
101
- }
102
- get backupDelay() {
103
- return this.model?.configuration?.backupDelay;
104
- }
105
- async backup(token) {
106
- let content = undefined;
107
- if (this.isResolved()) {
108
- content = await raceCancellation(this.model.snapshot(token), token);
109
- }
110
- else if (this.initialContents) {
111
- content = this.initialContents.value;
112
- }
113
- return { content };
114
- }
115
- async save(options) {
116
- this.trace('save()');
117
- const result = await this.saveDelegate(this, options);
118
- if (result) {
119
- this._onDidSave.fire({ reason: options?.reason, source: options?.source });
120
- }
121
- return result;
122
- }
123
- async revert() {
124
- this.trace('revert()');
125
- this.setModified(false);
126
- this._onDidRevert.fire();
127
- this.dispose();
128
- }
129
- dispose() {
130
- this.trace('dispose()');
131
- this._onWillDispose.fire();
132
- super.dispose();
133
- }
134
- trace(msg) {
135
- this.logService.trace(`[untitled file working copy] ${msg}`, ( this.resource.toString()), this.typeId);
136
- }
137
- };
138
- UntitledFileWorkingCopy = ( __decorate([
139
- ( __param(8, IWorkingCopyService)),
140
- ( __param(9, IWorkingCopyBackupService)),
141
- ( __param(10, ILogService))
142
- ], UntitledFileWorkingCopy));
143
-
144
- export { UntitledFileWorkingCopy };
@@ -1,129 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { DisposableStore, dispose } from 'vscode/vscode/vs/base/common/lifecycle';
3
- import { URI } from 'vscode/vscode/vs/base/common/uri';
4
- import { UntitledFileWorkingCopy } from './untitledFileWorkingCopy.js';
5
- import { Emitter } from 'vscode/vscode/vs/base/common/event';
6
- import { Schemas } from 'vscode/vscode/vs/base/common/network';
7
- import { IWorkingCopyService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyService';
8
- import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label';
9
- import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
10
- import { IWorkingCopyBackupService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyBackup';
11
- import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
12
- import { BaseFileWorkingCopyManager } from './abstractFileWorkingCopyManager.js';
13
- import { ResourceMap } from 'vscode/vscode/vs/base/common/map';
14
-
15
- let UntitledFileWorkingCopyManager = class UntitledFileWorkingCopyManager extends BaseFileWorkingCopyManager {
16
- constructor(workingCopyTypeId, modelFactory, saveDelegate, fileService, labelService, logService, workingCopyBackupService, workingCopyService) {
17
- super(fileService, logService, workingCopyBackupService);
18
- this.workingCopyTypeId = workingCopyTypeId;
19
- this.modelFactory = modelFactory;
20
- this.saveDelegate = saveDelegate;
21
- this.labelService = labelService;
22
- this.workingCopyService = workingCopyService;
23
- this._onDidChangeDirty = this._register(( new Emitter()));
24
- this.onDidChangeDirty = this._onDidChangeDirty.event;
25
- this._onWillDispose = this._register(( new Emitter()));
26
- this.onWillDispose = this._onWillDispose.event;
27
- this.mapResourceToWorkingCopyListeners = ( new ResourceMap());
28
- }
29
- async resolve(options) {
30
- const workingCopy = this.doCreateOrGet(options);
31
- await workingCopy.resolve();
32
- return workingCopy;
33
- }
34
- doCreateOrGet(options = Object.create(null)) {
35
- const massagedOptions = this.massageOptions(options);
36
- if (massagedOptions.untitledResource) {
37
- const existingWorkingCopy = this.get(massagedOptions.untitledResource);
38
- if (existingWorkingCopy) {
39
- return existingWorkingCopy;
40
- }
41
- }
42
- return this.doCreate(massagedOptions);
43
- }
44
- massageOptions(options) {
45
- const massagedOptions = Object.create(null);
46
- if (options.associatedResource) {
47
- massagedOptions.untitledResource = ( URI.from({
48
- scheme: Schemas.untitled,
49
- authority: options.associatedResource.authority,
50
- fragment: options.associatedResource.fragment,
51
- path: options.associatedResource.path,
52
- query: options.associatedResource.query
53
- }));
54
- massagedOptions.associatedResource = options.associatedResource;
55
- }
56
- else {
57
- if (options.untitledResource?.scheme === Schemas.untitled) {
58
- massagedOptions.untitledResource = options.untitledResource;
59
- }
60
- massagedOptions.isScratchpad = options.isScratchpad;
61
- }
62
- massagedOptions.contents = options.contents;
63
- return massagedOptions;
64
- }
65
- doCreate(options) {
66
- let untitledResource = options.untitledResource;
67
- if (!untitledResource) {
68
- let counter = 1;
69
- do {
70
- untitledResource = ( URI.from({
71
- scheme: Schemas.untitled,
72
- path: options.isScratchpad ? `Scratchpad-${counter}` : `Untitled-${counter}`,
73
- query: this.workingCopyTypeId ?
74
- `typeId=${this.workingCopyTypeId}` :
75
- undefined
76
- }));
77
- counter++;
78
- } while (( this.has(untitledResource)));
79
- }
80
- const workingCopy = ( new UntitledFileWorkingCopy(
81
- this.workingCopyTypeId,
82
- untitledResource,
83
- this.labelService.getUriBasenameLabel(untitledResource),
84
- !!options.associatedResource,
85
- !!options.isScratchpad,
86
- options.contents,
87
- this.modelFactory,
88
- this.saveDelegate,
89
- this.workingCopyService,
90
- this.workingCopyBackupService,
91
- this.logService
92
- ));
93
- this.registerWorkingCopy(workingCopy);
94
- return workingCopy;
95
- }
96
- registerWorkingCopy(workingCopy) {
97
- const workingCopyListeners = ( new DisposableStore());
98
- workingCopyListeners.add(workingCopy.onDidChangeDirty(() => this._onDidChangeDirty.fire(workingCopy)));
99
- workingCopyListeners.add(workingCopy.onWillDispose(() => this._onWillDispose.fire(workingCopy)));
100
- this.mapResourceToWorkingCopyListeners.set(workingCopy.resource, workingCopyListeners);
101
- this.add(workingCopy.resource, workingCopy);
102
- if (workingCopy.isDirty()) {
103
- this._onDidChangeDirty.fire(workingCopy);
104
- }
105
- }
106
- remove(resource) {
107
- const removed = super.remove(resource);
108
- const workingCopyListener = this.mapResourceToWorkingCopyListeners.get(resource);
109
- if (workingCopyListener) {
110
- dispose(workingCopyListener);
111
- this.mapResourceToWorkingCopyListeners.delete(resource);
112
- }
113
- return removed;
114
- }
115
- dispose() {
116
- super.dispose();
117
- dispose(( this.mapResourceToWorkingCopyListeners.values()));
118
- this.mapResourceToWorkingCopyListeners.clear();
119
- }
120
- };
121
- UntitledFileWorkingCopyManager = ( __decorate([
122
- ( __param(3, IFileService)),
123
- ( __param(4, ILabelService)),
124
- ( __param(5, ILogService)),
125
- ( __param(6, IWorkingCopyBackupService)),
126
- ( __param(7, IWorkingCopyService))
127
- ], UntitledFileWorkingCopyManager));
128
-
129
- export { UntitledFileWorkingCopyManager };