@codingame/monaco-vscode-working-copy-service-override 14.0.6 → 15.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": "14.0.6",
3
+ "version": "15.0.0",
4
4
  "private": false,
5
5
  "description": "VSCode public API plugged on the monaco editor - working-copy service-override",
6
6
  "keywords": [],
@@ -15,10 +15,10 @@
15
15
  },
16
16
  "type": "module",
17
17
  "dependencies": {
18
- "@codingame/monaco-vscode-99f24462-c56d-5407-83fb-2ea9dd33cc8c-common": "14.0.6",
19
- "@codingame/monaco-vscode-api": "14.0.6",
20
- "@codingame/monaco-vscode-ce8c4b18-4e75-55dd-9656-517347af9de7-common": "14.0.6",
21
- "@codingame/monaco-vscode-files-service-override": "14.0.6"
18
+ "@codingame/monaco-vscode-86d65fc6-30f9-5dca-9501-e249de688591-common": "15.0.0",
19
+ "@codingame/monaco-vscode-api": "15.0.0",
20
+ "@codingame/monaco-vscode-bba55be6-41a2-50cd-a3cc-8bafa35bfa89-common": "15.0.0",
21
+ "@codingame/monaco-vscode-files-service-override": "15.0.0"
22
22
  },
23
23
  "main": "index.js",
24
24
  "module": "index.js",
@@ -6,7 +6,7 @@ import { VSBufferReadable, VSBufferReadableStream } from "@codingame/monaco-vsco
6
6
  import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
7
7
  import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
8
8
  import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
9
- import { IWorkingCopyBackupMeta, IWorkingCopyIdentifier } from "@codingame/monaco-vscode-ce8c4b18-4e75-55dd-9656-517347af9de7-common/vscode/vs/workbench/services/workingCopy/common/workingCopy";
9
+ import { IWorkingCopyBackupMeta, IWorkingCopyIdentifier } from "@codingame/monaco-vscode-86d65fc6-30f9-5dca-9501-e249de688591-common/vscode/vs/workbench/services/workingCopy/common/workingCopy";
10
10
  export declare class WorkingCopyBackupsModel {
11
11
  private backupRoot;
12
12
  private fileService;
@@ -15,7 +15,7 @@ import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log
15
15
  import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
16
16
  import { hash } from '@codingame/monaco-vscode-api/vscode/vs/base/common/hash';
17
17
  import { isEmptyObject } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
18
- import { NO_TYPE_ID } from '@codingame/monaco-vscode-ce8c4b18-4e75-55dd-9656-517347af9de7-common/vscode/vs/workbench/services/workingCopy/common/workingCopy';
18
+ import { NO_TYPE_ID } from '@codingame/monaco-vscode-86d65fc6-30f9-5dca-9501-e249de688591-common/vscode/vs/workbench/services/workingCopy/common/workingCopy';
19
19
 
20
20
  var WorkingCopyBackupServiceImpl_1;
21
21
  class WorkingCopyBackupsModel {
@@ -1,6 +1,6 @@
1
1
  import { IEditorIdentifier } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor";
2
2
  import { EditorInput } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor/editorInput";
3
- import { IWorkingCopy, IWorkingCopyIdentifier } from "@codingame/monaco-vscode-ce8c4b18-4e75-55dd-9656-517347af9de7-common/vscode/vs/workbench/services/workingCopy/common/workingCopy";
3
+ import { IWorkingCopy, IWorkingCopyIdentifier } from "@codingame/monaco-vscode-86d65fc6-30f9-5dca-9501-e249de688591-common/vscode/vs/workbench/services/workingCopy/common/workingCopy";
4
4
  import { Disposable, IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
5
5
  import { IEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service";
6
6
  import { IWorkingCopyEditorService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/workingCopy/common/workingCopyEditorService.service";
@@ -33,7 +33,7 @@ import { escapeRegExpCharacters } from '@codingame/monaco-vscode-api/vscode/vs/b
33
33
  var WorkingCopyHistoryService_1, NativeWorkingCopyHistoryService_1;
34
34
  class WorkingCopyHistoryModel {
35
35
  static { this.ENTRIES_FILE = 'entries.json'; }
36
- static { this.FILE_SAVED_SOURCE = SaveSourceRegistry.registerSource('default.source', ( localize(12349, "File Saved"))); }
36
+ static { this.FILE_SAVED_SOURCE = SaveSourceRegistry.registerSource('default.source', ( localize(12461, "File Saved"))); }
37
37
  static { this.SETTINGS = {
38
38
  MAX_ENTRIES: 'workbench.localHistory.maxFileEntries',
39
39
  MERGE_PERIOD: 'workbench.localHistory.mergeWindow'
@@ -379,8 +379,8 @@ class WorkingCopyHistoryModel {
379
379
  }
380
380
  let WorkingCopyHistoryService = class WorkingCopyHistoryService extends Disposable {
381
381
  static { WorkingCopyHistoryService_1 = this; }
382
- static { this.FILE_MOVED_SOURCE = SaveSourceRegistry.registerSource('moved.source', ( localize(12350, "File Moved"))); }
383
- static { this.FILE_RENAMED_SOURCE = SaveSourceRegistry.registerSource('renamed.source', ( localize(12351, "File Renamed"))); }
382
+ static { this.FILE_MOVED_SOURCE = SaveSourceRegistry.registerSource('moved.source', ( localize(12462, "File Moved"))); }
383
+ static { this.FILE_RENAMED_SOURCE = SaveSourceRegistry.registerSource('renamed.source', ( localize(12463, "File Renamed"))); }
384
384
  constructor(fileService, remoteAgentService, environmentService, uriIdentityService, labelService, logService, configurationService) {
385
385
  super();
386
386
  this.fileService = fileService;
@@ -597,7 +597,7 @@ let NativeWorkingCopyHistoryService = class NativeWorkingCopyHistoryService exte
597
597
  onWillShutdown(e) {
598
598
  this.storeAllScheduler.dispose();
599
599
  this.storeAllCts.dispose(true);
600
- e.join(this.storeAll(e.token), { id: 'join.workingCopyHistory', label: ( localize(12352, "Saving local history")) });
600
+ e.join(this.storeAll(e.token), { id: 'join.workingCopyHistory', label: ( localize(12464, "Saving local history")) });
601
601
  }
602
602
  onDidChangeModels() {
603
603
  if (!this.storeAllScheduler.isScheduled()) {
@@ -10,12 +10,12 @@ import { IUndoRedoService } from '@codingame/monaco-vscode-api/vscode/vs/platfor
10
10
  import { IUriIdentityService } from '@codingame/monaco-vscode-api/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
11
11
  import { SaveSourceRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/editor';
12
12
  import { IPathService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/path/common/pathService.service';
13
- import { isStoredFileWorkingCopySaveEvent } from '@codingame/monaco-vscode-99f24462-c56d-5407-83fb-2ea9dd33cc8c-common/vscode/vs/workbench/services/workingCopy/common/storedFileWorkingCopy';
13
+ import { isStoredFileWorkingCopySaveEvent } from '@codingame/monaco-vscode-bba55be6-41a2-50cd-a3cc-8bafa35bfa89-common/vscode/vs/workbench/services/workingCopy/common/storedFileWorkingCopy';
14
14
  import { MAX_PARALLEL_HISTORY_IO_OPS } from './workingCopyHistory.js';
15
15
  import { IWorkingCopyHistoryService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/workingCopy/common/workingCopyHistory.service';
16
16
  import { IWorkingCopyService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/workingCopy/common/workingCopyService.service';
17
17
  import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
18
- import { ResourceGlobMatcher } from '@codingame/monaco-vscode-ce8c4b18-4e75-55dd-9656-517347af9de7-common/vscode/vs/workbench/common/resources';
18
+ import { ResourceGlobMatcher } from '@codingame/monaco-vscode-86d65fc6-30f9-5dca-9501-e249de688591-common/vscode/vs/workbench/common/resources';
19
19
  import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
20
20
  import { FileOperation } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files';
21
21
  import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
@@ -28,7 +28,7 @@ let WorkingCopyHistoryTracker = class WorkingCopyHistoryTracker extends Disposab
28
28
  SIZE_LIMIT: 'workbench.localHistory.maxFileSize',
29
29
  EXCLUDES: 'workbench.localHistory.exclude'
30
30
  }; }
31
- static { this.UNDO_REDO_SAVE_SOURCE = SaveSourceRegistry.registerSource('undoRedo.source', ( localize(12353, "Undo / Redo"))); }
31
+ static { this.UNDO_REDO_SAVE_SOURCE = SaveSourceRegistry.registerSource('undoRedo.source', ( localize(12465, "Undo / Redo"))); }
32
32
  constructor(workingCopyService, workingCopyHistoryService, uriIdentityService, pathService, configurationService, undoRedoService, contextService, fileService) {
33
33
  super();
34
34
  this.workingCopyService = workingCopyService;
@@ -1,6 +1,6 @@
1
1
  import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
2
2
  import { Disposable, IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
3
- import { IWorkingCopy, IWorkingCopyIdentifier, IWorkingCopySaveEvent as IBaseWorkingCopySaveEvent } from "@codingame/monaco-vscode-ce8c4b18-4e75-55dd-9656-517347af9de7-common/vscode/vs/workbench/services/workingCopy/common/workingCopy";
3
+ import { IWorkingCopy, IWorkingCopyIdentifier, IWorkingCopySaveEvent as IBaseWorkingCopySaveEvent } from "@codingame/monaco-vscode-86d65fc6-30f9-5dca-9501-e249de688591-common/vscode/vs/workbench/services/workingCopy/common/workingCopy";
4
4
  import { IWorkingCopyService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/workingCopy/common/workingCopyService.service";
5
5
  export interface IWorkingCopySaveEvent extends IBaseWorkingCopySaveEvent {
6
6
  readonly workingCopy: IWorkingCopy;
@@ -27,6 +27,12 @@ export declare class WorkingCopyService extends Disposable implements IWorkingCo
27
27
  has(resource: URI): boolean;
28
28
  get(identifier: IWorkingCopyIdentifier): IWorkingCopy | undefined;
29
29
  getAll(resource: URI): readonly IWorkingCopy[] | undefined;
30
+ private static readonly LEAK_TRACKING_THRESHOLD;
31
+ private static readonly LEAK_REPORTING_THRESHOLD;
32
+ private static LEAK_REPORTED;
33
+ private readonly mapLeakToCounter;
34
+ private trackLeaks;
35
+ private untrackLeaks;
30
36
  get hasDirty(): boolean;
31
37
  get dirtyCount(): number;
32
38
  get dirtyWorkingCopies(): IWorkingCopy[];
@@ -4,8 +4,16 @@ import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/even
4
4
  import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
5
5
  import { Disposable, DisposableMap, DisposableStore, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
6
6
  import { ResourceMap } from '@codingame/monaco-vscode-api/vscode/vs/base/common/map';
7
+ import { onUnexpectedError } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
7
8
  import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
8
9
 
10
+ class WorkingCopyLeakError extends Error {
11
+ constructor(message, stack) {
12
+ super(message);
13
+ this.name = 'WorkingCopyLeakError';
14
+ this.stack = stack;
15
+ }
16
+ }
9
17
  class WorkingCopyService extends Disposable {
10
18
  constructor() {
11
19
  super(...arguments);
@@ -22,6 +30,7 @@ class WorkingCopyService extends Disposable {
22
30
  this._workingCopies = ( new Set());
23
31
  this.mapResourceToWorkingCopies = ( new ResourceMap());
24
32
  this.mapWorkingCopyToListeners = this._register(( new DisposableMap()));
33
+ this.mapLeakToCounter = ( new Map());
25
34
  }
26
35
  get workingCopies() { return Array.from(( this._workingCopies.values())); }
27
36
  registerWorkingCopy(workingCopy) {
@@ -46,7 +55,11 @@ class WorkingCopyService extends Disposable {
46
55
  if (workingCopy.isDirty()) {
47
56
  this._onDidChangeDirty.fire(workingCopy);
48
57
  }
58
+ const leakId = this.trackLeaks(workingCopy);
49
59
  return toDisposable(() => {
60
+ if (leakId) {
61
+ this.untrackLeaks(leakId);
62
+ }
50
63
  this.unregisterWorkingCopy(workingCopy);
51
64
  this._onDidUnregister.fire(workingCopy);
52
65
  });
@@ -78,6 +91,31 @@ class WorkingCopyService extends Disposable {
78
91
  }
79
92
  return Array.from(( workingCopies.values()));
80
93
  }
94
+ static { this.LEAK_TRACKING_THRESHOLD = 256; }
95
+ static { this.LEAK_REPORTING_THRESHOLD = 2 * WorkingCopyService.LEAK_TRACKING_THRESHOLD; }
96
+ static { this.LEAK_REPORTED = false; }
97
+ trackLeaks(workingCopy) {
98
+ if (WorkingCopyService.LEAK_REPORTED || this._workingCopies.size < WorkingCopyService.LEAK_TRACKING_THRESHOLD) {
99
+ return undefined;
100
+ }
101
+ const leakId = `${workingCopy.resource.scheme}#${workingCopy.typeId || '<no typeId>'}\n${( new Error()).stack?.split('\n').slice(2).join('\n') ?? ''}`;
102
+ const leakCounter = (this.mapLeakToCounter.get(leakId) ?? 0) + 1;
103
+ this.mapLeakToCounter.set(leakId, leakCounter);
104
+ if (this._workingCopies.size > WorkingCopyService.LEAK_REPORTING_THRESHOLD) {
105
+ WorkingCopyService.LEAK_REPORTED = true;
106
+ const [topLeak, topCount] = Array.from(this.mapLeakToCounter.entries()).reduce(([topLeak, topCount], [key, val]) => val > topCount ? [key, val] : [topLeak, topCount]);
107
+ const message = `Potential working copy LEAK detected, having ${this._workingCopies.size} working copies already. Most frequent owner (${topCount})`;
108
+ onUnexpectedError(( new WorkingCopyLeakError(message, topLeak)));
109
+ }
110
+ return leakId;
111
+ }
112
+ untrackLeaks(leakId) {
113
+ const stackCounter = (this.mapLeakToCounter.get(leakId) ?? 1) - 1;
114
+ this.mapLeakToCounter.set(leakId, stackCounter);
115
+ if (stackCounter === 0) {
116
+ this.mapLeakToCounter.delete(leakId);
117
+ }
118
+ }
81
119
  get hasDirty() {
82
120
  for (const workingCopy of this._workingCopies) {
83
121
  if (workingCopy.isDirty()) {