@codingame/monaco-vscode-working-copy-service-override 5.2.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-working-copy-service-override",
3
- "version": "5.2.0",
3
+ "version": "6.0.0",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -26,7 +26,7 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "vscode": "npm:@codingame/monaco-vscode-api@5.2.0",
30
- "@codingame/monaco-vscode-files-service-override": "5.2.0"
29
+ "vscode": "npm:@codingame/monaco-vscode-api@6.0.0",
30
+ "@codingame/monaco-vscode-files-service-override": "6.0.0"
31
31
  }
32
32
  }
@@ -3,10 +3,11 @@ import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.servi
3
3
  import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
4
4
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
5
5
  import { WorkingCopyBackupService } from '../common/workingCopyBackupService.js';
6
+ import 'vscode/vscode/vs/platform/instantiation/common/extensions';
6
7
  import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
7
8
  import { joinPath } from 'vscode/vscode/vs/base/common/resources';
8
9
  import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
9
- import { registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
10
+ import { registerWorkbenchContribution2, WorkbenchPhase } from 'vscode/vscode/vs/workbench/common/contributions';
10
11
  import { BrowserWorkingCopyBackupTracker } from './workingCopyBackupTracker.js';
11
12
 
12
13
  let BrowserWorkingCopyBackupService = class BrowserWorkingCopyBackupService extends WorkingCopyBackupService {
@@ -20,6 +21,6 @@ BrowserWorkingCopyBackupService = ( __decorate([
20
21
  ( __param(2, IFileService)),
21
22
  ( __param(3, ILogService))
22
23
  ], BrowserWorkingCopyBackupService));
23
- registerWorkbenchContribution2(BrowserWorkingCopyBackupTracker.ID, BrowserWorkingCopyBackupTracker, 1 );
24
+ registerWorkbenchContribution2(BrowserWorkingCopyBackupTracker.ID, BrowserWorkingCopyBackupTracker, WorkbenchPhase.BlockStartup);
24
25
 
25
26
  export { BrowserWorkingCopyBackupService };
@@ -7,6 +7,7 @@ import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label.serv
7
7
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
8
8
  import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
9
9
  import { WorkingCopyHistoryService } from '../common/workingCopyHistoryService.js';
10
+ import 'vscode/vscode/vs/platform/instantiation/common/extensions';
10
11
  import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
11
12
 
12
13
  let BrowserWorkingCopyHistoryService = class BrowserWorkingCopyHistoryService extends WorkingCopyHistoryService {
@@ -4,6 +4,7 @@ import { URI } from 'vscode/vscode/vs/base/common/uri';
4
4
  import { coalesce } from 'vscode/vscode/vs/base/common/arrays';
5
5
  import { deepClone, equals } from 'vscode/vscode/vs/base/common/objects';
6
6
  import { Promises, ResourceQueue } from 'vscode/vscode/vs/base/common/async';
7
+ import { FileOperationResult } from 'vscode/vscode/vs/platform/files/common/files';
7
8
  import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
8
9
  import { ResourceMap } from 'vscode/vscode/vs/base/common/map';
9
10
  import { isReadableStream, peekStream } from 'vscode/vscode/vs/base/common/stream';
@@ -255,7 +256,7 @@ let WorkingCopyBackupServiceImpl = class WorkingCopyBackupServiceImpl extends Di
255
256
  await this.fileService.del(backupResource, { recursive: true });
256
257
  }
257
258
  catch (error) {
258
- if (error.fileOperationResult !== 1 ) {
259
+ if (error.fileOperationResult !== FileOperationResult.FILE_NOT_FOUND) {
259
260
  throw error;
260
261
  }
261
262
  }
@@ -1,6 +1,9 @@
1
1
  import { Disposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
2
+ import { WorkingCopyCapabilities } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopy';
3
+ import { LifecyclePhase } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
2
4
  import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
3
5
  import { Promises } from 'vscode/vscode/vs/base/common/async';
6
+ import { EditorsOrder } from 'vscode/vscode/vs/workbench/common/editor';
4
7
 
5
8
  class WorkingCopyBackupTracker extends Disposable {
6
9
  constructor(workingCopyBackupService, workingCopyService, logService, lifecycleService, filesConfigurationService, workingCopyEditorService, editorService, editorGroupService) {
@@ -126,7 +129,7 @@ class WorkingCopyBackupTracker extends Disposable {
126
129
  return workingCopy.backupDelay;
127
130
  }
128
131
  let backupScheduleDelay;
129
- if (workingCopy.capabilities & 2 ) {
132
+ if (workingCopy.capabilities & WorkingCopyCapabilities.Untitled) {
130
133
  backupScheduleDelay = 'default';
131
134
  }
132
135
  else {
@@ -198,7 +201,7 @@ class WorkingCopyBackupTracker extends Disposable {
198
201
  }
199
202
  get isReady() { return this._isReady; }
200
203
  async resolveBackupsToRestore() {
201
- await this.lifecycleService.when(3 );
204
+ await this.lifecycleService.when(LifecyclePhase.Restored);
202
205
  for (const backup of await this.workingCopyBackupService.getBackups()) {
203
206
  this.unrestoredBackups.add(backup);
204
207
  }
@@ -215,7 +218,7 @@ class WorkingCopyBackupTracker extends Disposable {
215
218
  continue;
216
219
  }
217
220
  let hasOpenedEditorForBackup = false;
218
- for (const { editor } of this.editorService.getEditors(0 )) {
221
+ for (const { editor } of this.editorService.getEditors(EditorsOrder.MOST_RECENTLY_ACTIVE)) {
219
222
  const isUnrestoredBackupOpened = handler.isOpen(unrestoredBackup, editor);
220
223
  if (isUnrestoredBackupOpened) {
221
224
  openedEditorsForBackups.add(editor);
@@ -1,5 +1,7 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import { Emitter } from 'vscode/vscode/vs/base/common/event';
3
+ import 'vscode/vscode/vs/platform/instantiation/common/extensions';
4
+ import { EditorsOrder } from 'vscode/vscode/vs/workbench/common/editor';
3
5
  import { Disposable, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
4
6
  import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
5
7
  import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
@@ -18,7 +20,7 @@ let WorkingCopyEditorService = class WorkingCopyEditorService extends Disposable
18
20
  return toDisposable(() => this.handlers.delete(handler));
19
21
  }
20
22
  findEditor(workingCopy) {
21
- for (const editorIdentifier of this.editorService.getEditors(0 )) {
23
+ for (const editorIdentifier of this.editorService.getEditors(EditorsOrder.MOST_RECENTLY_ACTIVE)) {
22
24
  if (this.isOpen(workingCopy, editorIdentifier.editor)) {
23
25
  return editorIdentifier;
24
26
  }
@@ -4,11 +4,12 @@ import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
4
4
  import { assertIsDefined } from 'vscode/vscode/vs/base/common/types';
5
5
  import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
6
6
  import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
7
+ import { LifecyclePhase } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
7
8
  import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
8
9
  import { WorkingCopyHistoryTracker } from './workingCopyHistoryTracker.js';
9
10
  import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
10
11
  import { MAX_PARALLEL_HISTORY_IO_OPS } from './workingCopyHistory.js';
11
- import { FileOperationError } from 'vscode/vscode/vs/platform/files/common/files';
12
+ import { FileOperationError, FileOperationResult } from 'vscode/vscode/vs/platform/files/common/files';
12
13
  import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
13
14
  import { IRemoteAgentService } from 'vscode/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
14
15
  import { URI } from 'vscode/vscode/vs/base/common/uri';
@@ -25,7 +26,7 @@ import { VSBuffer } from 'vscode/vscode/vs/base/common/buffer';
25
26
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
26
27
  import { SaveSourceRegistry } from 'vscode/vscode/vs/workbench/common/editor';
27
28
  import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
28
- import { lastOrDefault } from 'vscode/vscode/vs/base/common/arrays';
29
+ import { lastOrDefault, distinct } from 'vscode/vscode/vs/base/common/arrays';
29
30
  import { escapeRegExpCharacters } from 'vscode/vscode/vs/base/common/strings';
30
31
 
31
32
  var WorkingCopyHistoryService_1, NativeWorkingCopyHistoryService_1;
@@ -72,7 +73,7 @@ class WorkingCopyHistoryModel {
72
73
  toHistoryEntriesFolder(historyHome, workingCopyResource) {
73
74
  return joinPath(historyHome, ( (hash(( (workingCopyResource.toString()))).toString(16))));
74
75
  }
75
- async addEntry(source = WorkingCopyHistoryModel.FILE_SAVED_SOURCE, timestamp = Date.now(), token) {
76
+ async addEntry(source = WorkingCopyHistoryModel.FILE_SAVED_SOURCE, sourceDescription = undefined, timestamp = Date.now(), token) {
76
77
  let entryToReplace = undefined;
77
78
  const lastEntry = lastOrDefault(this.entries);
78
79
  if (lastEntry && lastEntry.source === source) {
@@ -83,17 +84,17 @@ class WorkingCopyHistoryModel {
83
84
  }
84
85
  let entry;
85
86
  if (entryToReplace) {
86
- entry = await this.doReplaceEntry(entryToReplace, timestamp, token);
87
+ entry = await this.doReplaceEntry(entryToReplace, source, sourceDescription, timestamp, token);
87
88
  }
88
89
  else {
89
- entry = await this.doAddEntry(source, timestamp, token);
90
+ entry = await this.doAddEntry(source, sourceDescription, timestamp, token);
90
91
  }
91
92
  if (this.options.flushOnChange && !token.isCancellationRequested) {
92
93
  await this.store(token);
93
94
  }
94
95
  return entry;
95
96
  }
96
- async doAddEntry(source, timestamp, token) {
97
+ async doAddEntry(source, sourceDescription = undefined, timestamp, token) {
97
98
  const workingCopyResource = assertIsDefined(this.workingCopyResource);
98
99
  const workingCopyName = assertIsDefined(this.workingCopyName);
99
100
  const historyEntriesFolder = assertIsDefined(this.historyEntriesFolder);
@@ -105,16 +106,19 @@ class WorkingCopyHistoryModel {
105
106
  workingCopy: { resource: workingCopyResource, name: workingCopyName },
106
107
  location,
107
108
  timestamp,
108
- source
109
+ source,
110
+ sourceDescription
109
111
  };
110
112
  this.entries.push(entry);
111
113
  this.versionId++;
112
114
  this.entryAddedEmitter.fire({ entry });
113
115
  return entry;
114
116
  }
115
- async doReplaceEntry(entry, timestamp, token) {
117
+ async doReplaceEntry(entry, source, sourceDescription = undefined, timestamp, token) {
116
118
  const workingCopyResource = assertIsDefined(this.workingCopyResource);
117
119
  await this.fileService.cloneFile(workingCopyResource, entry.location);
120
+ entry.source = source;
121
+ entry.sourceDescription = sourceDescription;
118
122
  entry.timestamp = timestamp;
119
123
  this.versionId++;
120
124
  this.entryReplacedEmitter.fire({ entry });
@@ -196,7 +200,8 @@ class WorkingCopyHistoryModel {
196
200
  workingCopy: { resource: workingCopyResource, name: workingCopyName },
197
201
  location: entryStat.resource,
198
202
  timestamp: entryStat.mtime,
199
- source: WorkingCopyHistoryModel.FILE_SAVED_SOURCE
203
+ source: WorkingCopyHistoryModel.FILE_SAVED_SOURCE,
204
+ sourceDescription: undefined
200
205
  });
201
206
  }
202
207
  }
@@ -207,30 +212,55 @@ class WorkingCopyHistoryModel {
207
212
  entries.set(entry.id, {
208
213
  ...existingEntry,
209
214
  timestamp: entry.timestamp,
210
- source: entry.source ?? existingEntry.source
215
+ source: entry.source ?? existingEntry.source,
216
+ sourceDescription: entry.sourceDescription ?? existingEntry.sourceDescription
211
217
  });
212
218
  }
213
219
  }
214
220
  }
215
221
  return entries;
216
222
  }
217
- async moveEntries(targetWorkingCopyResource, source, token) {
218
- await this.store(token);
219
- if (token.isCancellationRequested) {
220
- return undefined;
221
- }
223
+ async moveEntries(target, source, token) {
224
+ const timestamp = Date.now();
225
+ const sourceDescription = this.labelService.getUriLabel(assertIsDefined(this.workingCopyResource));
222
226
  const sourceHistoryEntriesFolder = assertIsDefined(this.historyEntriesFolder);
223
- const targetHistoryFolder = this.toHistoryEntriesFolder(this.historyHome, targetWorkingCopyResource);
227
+ const targetHistoryEntriesFolder = assertIsDefined(target.historyEntriesFolder);
224
228
  try {
225
- await this.fileService.move(sourceHistoryEntriesFolder, targetHistoryFolder, true);
229
+ for (const entry of this.entries) {
230
+ await this.fileService.move(entry.location, joinPath(targetHistoryEntriesFolder, entry.id), true);
231
+ }
232
+ await this.fileService.del(sourceHistoryEntriesFolder, { recursive: true });
226
233
  }
227
234
  catch (error) {
228
- if (!((error instanceof FileOperationError && error.fileOperationResult === 1) )) {
229
- this.traceError(error);
235
+ if (!this.isFileNotFound(error)) {
236
+ try {
237
+ await this.fileService.move(sourceHistoryEntriesFolder, targetHistoryEntriesFolder, true);
238
+ }
239
+ catch (error) {
240
+ if (!this.isFileNotFound(error)) {
241
+ this.traceError(error);
242
+ }
243
+ }
230
244
  }
231
245
  }
246
+ const allEntries = distinct([...this.entries, ...target.entries], entry => entry.id).sort((entryA, entryB) => entryA.timestamp - entryB.timestamp);
247
+ const targetWorkingCopyResource = assertIsDefined(target.workingCopyResource);
232
248
  this.setWorkingCopy(targetWorkingCopyResource);
233
- await this.addEntry(source, undefined, token);
249
+ const targetWorkingCopyName = assertIsDefined(target.workingCopyName);
250
+ for (const entry of allEntries) {
251
+ this.entries.push({
252
+ id: entry.id,
253
+ location: joinPath(targetHistoryEntriesFolder, entry.id),
254
+ source: entry.source,
255
+ sourceDescription: entry.sourceDescription,
256
+ timestamp: entry.timestamp,
257
+ workingCopy: {
258
+ resource: targetWorkingCopyResource,
259
+ name: targetWorkingCopyName
260
+ }
261
+ });
262
+ }
263
+ await this.addEntry(source, sourceDescription, timestamp, token);
234
264
  await this.store(token);
235
265
  }
236
266
  async store(token) {
@@ -301,6 +331,7 @@ class WorkingCopyHistoryModel {
301
331
  return {
302
332
  id: entry.id,
303
333
  source: entry.source !== WorkingCopyHistoryModel.FILE_SAVED_SOURCE ? entry.source : undefined,
334
+ sourceDescription: entry.sourceDescription,
304
335
  timestamp: entry.timestamp
305
336
  };
306
337
  })))
@@ -314,7 +345,7 @@ class WorkingCopyHistoryModel {
314
345
  serializedModel = JSON.parse(( ((await this.fileService.readFile(historyEntriesListingFile)).value.toString())));
315
346
  }
316
347
  catch (error) {
317
- if (!((error instanceof FileOperationError && error.fileOperationResult === 1) )) {
348
+ if (!this.isFileNotFound(error)) {
318
349
  this.traceError(error);
319
350
  }
320
351
  }
@@ -328,7 +359,7 @@ class WorkingCopyHistoryModel {
328
359
  rawEntries = (await this.fileService.resolve(historyEntriesFolder, { resolveMetadata: true })).children;
329
360
  }
330
361
  catch (error) {
331
- if (!((error instanceof FileOperationError && error.fileOperationResult === 1) )) {
362
+ if (!this.isFileNotFound(error)) {
332
363
  this.traceError(error);
333
364
  }
334
365
  }
@@ -339,6 +370,9 @@ class WorkingCopyHistoryModel {
339
370
  historyEntriesNameMatcher.test(entry.name)
340
371
  );
341
372
  }
373
+ isFileNotFound(error) {
374
+ return error instanceof FileOperationError && error.fileOperationResult === FileOperationResult.FILE_NOT_FOUND;
375
+ }
342
376
  traceError(error) {
343
377
  this.logService.trace('[Working Copy History Service]', error);
344
378
  }
@@ -419,10 +453,11 @@ let WorkingCopyHistoryService = class WorkingCopyHistoryService extends Disposab
419
453
  this._onDidMoveEntries.fire();
420
454
  return resources;
421
455
  }
422
- async doMoveEntries(model, source, sourceWorkingCopyResource, targetWorkingCopyResource) {
423
- await model.moveEntries(targetWorkingCopyResource, source, CancellationToken.None);
456
+ async doMoveEntries(source, saveSource, sourceWorkingCopyResource, targetWorkingCopyResource) {
457
+ const target = await this.getModel(targetWorkingCopyResource);
458
+ await source.moveEntries(target, saveSource, CancellationToken.None);
424
459
  this.models.delete(sourceWorkingCopyResource);
425
- this.models.set(targetWorkingCopyResource, model);
460
+ this.models.set(targetWorkingCopyResource, source);
426
461
  return targetWorkingCopyResource;
427
462
  }
428
463
  async addEntry({ resource, source, timestamp }, token) {
@@ -433,7 +468,7 @@ let WorkingCopyHistoryService = class WorkingCopyHistoryService extends Disposab
433
468
  if (token.isCancellationRequested) {
434
469
  return undefined;
435
470
  }
436
- return model.addEntry(source, timestamp, token);
471
+ return model.addEntry(source, undefined, timestamp, token);
437
472
  }
438
473
  async updateEntry(entry, properties, token) {
439
474
  const model = await this.getModel(entry.workingCopy.resource);
@@ -599,6 +634,6 @@ NativeWorkingCopyHistoryService = NativeWorkingCopyHistoryService_1 = ( (__decor
599
634
  ( (__param(6, ILogService))),
600
635
  ( (__param(7, IConfigurationService)))
601
636
  ], NativeWorkingCopyHistoryService)));
602
- ( (Registry.as(Extensions.Workbench))).registerWorkbenchContribution(WorkingCopyHistoryTracker, 3 );
637
+ ( (Registry.as(Extensions.Workbench))).registerWorkbenchContribution(WorkingCopyHistoryTracker, LifecyclePhase.Restored);
603
638
 
604
639
  export { NativeWorkingCopyHistoryService, WorkingCopyHistoryModel, WorkingCopyHistoryService };
@@ -16,6 +16,7 @@ import { IWorkingCopyService } from 'vscode/vscode/vs/workbench/services/working
16
16
  import { Schemas } from 'vscode/vscode/vs/base/common/network';
17
17
  import { ResourceGlobMatcher } from 'vscode/vscode/vs/workbench/common/resources';
18
18
  import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
19
+ import { FileOperation } from 'vscode/vscode/vs/platform/files/common/files';
19
20
  import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
20
21
 
21
22
  var WorkingCopyHistoryTracker_1;
@@ -126,7 +127,7 @@ let WorkingCopyHistoryTracker = class WorkingCopyHistoryTracker extends Disposab
126
127
  return this.shouldTrackHistory(e.workingCopy.resource, e.stat);
127
128
  }
128
129
  shouldTrackHistoryFromFileOperationEvent(e) {
129
- if (!e.isOperation(2 )) {
130
+ if (!e.isOperation(FileOperation.MOVE)) {
130
131
  return false;
131
132
  }
132
133
  return this.shouldTrackHistory(e.target.resource, e.target);
@@ -1,3 +1,4 @@
1
+ import 'vscode/vscode/vs/platform/instantiation/common/extensions';
1
2
  import { Emitter } from 'vscode/vscode/vs/base/common/event';
2
3
  import { URI } from 'vscode/vscode/vs/base/common/uri';
3
4
  import { Disposable, DisposableMap, DisposableStore, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';