@codingame/monaco-vscode-working-copy-service-override 4.1.0 → 4.1.2
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/external/tslib/tslib.es6.js +11 -0
- package/package.json +3 -3
- package/vscode/src/vs/workbench/services/workingCopy/browser/workingCopyBackupService.js +25 -0
- package/vscode/src/vs/workbench/services/workingCopy/browser/workingCopyBackupTracker.js +45 -0
- package/vscode/src/vs/workbench/services/workingCopy/browser/workingCopyHistoryService.js +30 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyBackupService.js +454 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyBackupTracker.js +255 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyHistoryService.js +618 -0
- package/vscode/src/vs/workbench/services/workingCopy/common/workingCopyHistoryTracker.js +164 -0
- package/workingCopy.js +2 -2
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
3
|
+
import { Limiter, GlobalIdleValue } from 'vscode/vscode/vs/base/common/async';
|
|
4
|
+
import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
|
|
5
|
+
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
6
|
+
import { ResourceMap } from 'vscode/vscode/vs/base/common/map';
|
|
7
|
+
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
|
|
8
|
+
import { IUndoRedoService } from 'vscode/vscode/vs/platform/undoRedo/common/undoRedo';
|
|
9
|
+
import { IUriIdentityService } from 'vscode/vscode/vs/platform/uriIdentity/common/uriIdentity';
|
|
10
|
+
import { SaveSourceRegistry } from 'vscode/vscode/vs/workbench/common/editor';
|
|
11
|
+
import { IPathService } from 'vscode/vscode/vs/workbench/services/path/common/pathService';
|
|
12
|
+
import { isStoredFileWorkingCopySaveEvent } from 'vscode/vscode/vs/workbench/services/workingCopy/common/storedFileWorkingCopy';
|
|
13
|
+
import { MAX_PARALLEL_HISTORY_IO_OPS, IWorkingCopyHistoryService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyHistory';
|
|
14
|
+
import { IWorkingCopyService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyService';
|
|
15
|
+
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
16
|
+
import { ResourceGlobMatcher } from 'vscode/vscode/vs/workbench/common/resources';
|
|
17
|
+
import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace';
|
|
18
|
+
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
|
|
19
|
+
|
|
20
|
+
var WorkingCopyHistoryTracker_1;
|
|
21
|
+
let WorkingCopyHistoryTracker = class WorkingCopyHistoryTracker extends Disposable {
|
|
22
|
+
static { WorkingCopyHistoryTracker_1 = this; }
|
|
23
|
+
static { this.SETTINGS = {
|
|
24
|
+
ENABLED: 'workbench.localHistory.enabled',
|
|
25
|
+
SIZE_LIMIT: 'workbench.localHistory.maxFileSize',
|
|
26
|
+
EXCLUDES: 'workbench.localHistory.exclude'
|
|
27
|
+
}; }
|
|
28
|
+
static { this.UNDO_REDO_SAVE_SOURCE = SaveSourceRegistry.registerSource('undoRedo.source', ( localizeWithPath(
|
|
29
|
+
'vs/workbench/services/workingCopy/common/workingCopyHistoryTracker',
|
|
30
|
+
'undoRedo.source',
|
|
31
|
+
"Undo / Redo"
|
|
32
|
+
))); }
|
|
33
|
+
constructor(workingCopyService, workingCopyHistoryService, uriIdentityService, pathService, configurationService, undoRedoService, contextService, fileService) {
|
|
34
|
+
super();
|
|
35
|
+
this.workingCopyService = workingCopyService;
|
|
36
|
+
this.workingCopyHistoryService = workingCopyHistoryService;
|
|
37
|
+
this.uriIdentityService = uriIdentityService;
|
|
38
|
+
this.pathService = pathService;
|
|
39
|
+
this.configurationService = configurationService;
|
|
40
|
+
this.undoRedoService = undoRedoService;
|
|
41
|
+
this.contextService = contextService;
|
|
42
|
+
this.fileService = fileService;
|
|
43
|
+
this.limiter = this._register(( new Limiter(MAX_PARALLEL_HISTORY_IO_OPS)));
|
|
44
|
+
this.resourceExcludeMatcher = this._register(( new GlobalIdleValue(() => {
|
|
45
|
+
const matcher = this._register(( new ResourceGlobMatcher(
|
|
46
|
+
root => this.configurationService.getValue(WorkingCopyHistoryTracker_1.SETTINGS.EXCLUDES, { resource: root }),
|
|
47
|
+
event => event.affectsConfiguration(WorkingCopyHistoryTracker_1.SETTINGS.EXCLUDES),
|
|
48
|
+
this.contextService,
|
|
49
|
+
this.configurationService
|
|
50
|
+
)));
|
|
51
|
+
return matcher;
|
|
52
|
+
})));
|
|
53
|
+
this.pendingAddHistoryEntryOperations = ( new ResourceMap(resource => this.uriIdentityService.extUri.getComparisonKey(resource)));
|
|
54
|
+
this.workingCopyContentVersion = ( new ResourceMap(resource => this.uriIdentityService.extUri.getComparisonKey(resource)));
|
|
55
|
+
this.historyEntryContentVersion = ( new ResourceMap(resource => this.uriIdentityService.extUri.getComparisonKey(resource)));
|
|
56
|
+
this.registerListeners();
|
|
57
|
+
}
|
|
58
|
+
registerListeners() {
|
|
59
|
+
this._register(this.fileService.onDidRunOperation(e => this.onDidRunFileOperation(e)));
|
|
60
|
+
this._register(this.workingCopyService.onDidChangeContent(workingCopy => this.onDidChangeContent(workingCopy)));
|
|
61
|
+
this._register(this.workingCopyService.onDidSave(e => this.onDidSave(e)));
|
|
62
|
+
}
|
|
63
|
+
async onDidRunFileOperation(e) {
|
|
64
|
+
if (!this.shouldTrackHistoryFromFileOperationEvent(e)) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const source = e.resource;
|
|
68
|
+
const target = e.target.resource;
|
|
69
|
+
const resources = await this.workingCopyHistoryService.moveEntries(source, target);
|
|
70
|
+
for (const resource of resources) {
|
|
71
|
+
const contentVersion = this.getContentVersion(resource);
|
|
72
|
+
this.historyEntryContentVersion.set(resource, contentVersion);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
onDidChangeContent(workingCopy) {
|
|
76
|
+
const contentVersionId = this.getContentVersion(workingCopy.resource);
|
|
77
|
+
this.workingCopyContentVersion.set(workingCopy.resource, contentVersionId + 1);
|
|
78
|
+
}
|
|
79
|
+
getContentVersion(resource) {
|
|
80
|
+
return this.workingCopyContentVersion.get(resource) || 0;
|
|
81
|
+
}
|
|
82
|
+
onDidSave(e) {
|
|
83
|
+
if (!this.shouldTrackHistoryFromSaveEvent(e)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const contentVersion = this.getContentVersion(e.workingCopy.resource);
|
|
87
|
+
if (this.historyEntryContentVersion.get(e.workingCopy.resource) === contentVersion) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
this.pendingAddHistoryEntryOperations.get(e.workingCopy.resource)?.dispose(true);
|
|
91
|
+
const cts = ( new CancellationTokenSource());
|
|
92
|
+
this.pendingAddHistoryEntryOperations.set(e.workingCopy.resource, cts);
|
|
93
|
+
this.limiter.queue(async () => {
|
|
94
|
+
if (cts.token.isCancellationRequested) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const contentVersion = this.getContentVersion(e.workingCopy.resource);
|
|
98
|
+
let source = e.source;
|
|
99
|
+
if (!e.source) {
|
|
100
|
+
source = this.resolveSourceFromUndoRedo(e);
|
|
101
|
+
}
|
|
102
|
+
await this.workingCopyHistoryService.addEntry({ resource: e.workingCopy.resource, source, timestamp: e.stat.mtime }, cts.token);
|
|
103
|
+
this.historyEntryContentVersion.set(e.workingCopy.resource, contentVersion);
|
|
104
|
+
if (cts.token.isCancellationRequested) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
this.pendingAddHistoryEntryOperations.delete(e.workingCopy.resource);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
resolveSourceFromUndoRedo(e) {
|
|
111
|
+
const lastStackElement = this.undoRedoService.getLastElement(e.workingCopy.resource);
|
|
112
|
+
if (lastStackElement) {
|
|
113
|
+
if (lastStackElement.code === 'undoredo.textBufferEdit') {
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
return lastStackElement.label;
|
|
117
|
+
}
|
|
118
|
+
const allStackElements = this.undoRedoService.getElements(e.workingCopy.resource);
|
|
119
|
+
if (allStackElements.future.length > 0 || allStackElements.past.length > 0) {
|
|
120
|
+
return WorkingCopyHistoryTracker_1.UNDO_REDO_SAVE_SOURCE;
|
|
121
|
+
}
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
shouldTrackHistoryFromSaveEvent(e) {
|
|
125
|
+
if (!isStoredFileWorkingCopySaveEvent(e)) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
return this.shouldTrackHistory(e.workingCopy.resource, e.stat);
|
|
129
|
+
}
|
|
130
|
+
shouldTrackHistoryFromFileOperationEvent(e) {
|
|
131
|
+
if (!e.isOperation(2 )) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
return this.shouldTrackHistory(e.target.resource, e.target);
|
|
135
|
+
}
|
|
136
|
+
shouldTrackHistory(resource, stat) {
|
|
137
|
+
if (resource.scheme !== this.pathService.defaultUriScheme &&
|
|
138
|
+
resource.scheme !== Schemas.vscodeUserData &&
|
|
139
|
+
resource.scheme !== Schemas.inMemory
|
|
140
|
+
) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
const configuredMaxFileSizeInBytes = 1024 * this.configurationService.getValue(WorkingCopyHistoryTracker_1.SETTINGS.SIZE_LIMIT, { resource });
|
|
144
|
+
if (stat.size > configuredMaxFileSizeInBytes) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
if (this.configurationService.getValue(WorkingCopyHistoryTracker_1.SETTINGS.ENABLED, { resource }) === false) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
return !this.resourceExcludeMatcher.value.matches(resource);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
WorkingCopyHistoryTracker = WorkingCopyHistoryTracker_1 = ( __decorate([
|
|
154
|
+
( __param(0, IWorkingCopyService)),
|
|
155
|
+
( __param(1, IWorkingCopyHistoryService)),
|
|
156
|
+
( __param(2, IUriIdentityService)),
|
|
157
|
+
( __param(3, IPathService)),
|
|
158
|
+
( __param(4, IConfigurationService)),
|
|
159
|
+
( __param(5, IUndoRedoService)),
|
|
160
|
+
( __param(6, IWorkspaceContextService)),
|
|
161
|
+
( __param(7, IFileService))
|
|
162
|
+
], WorkingCopyHistoryTracker));
|
|
163
|
+
|
|
164
|
+
export { WorkingCopyHistoryTracker };
|
package/workingCopy.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
|
|
2
|
-
import { BrowserWorkingCopyBackupService } from 'vscode/
|
|
2
|
+
import { BrowserWorkingCopyBackupService } from './vscode/src/vs/workbench/services/workingCopy/browser/workingCopyBackupService.js';
|
|
3
3
|
import { IWorkingCopyBackupService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyBackup';
|
|
4
4
|
import { IWorkingCopyService, WorkingCopyService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyService';
|
|
5
5
|
import { IWorkingCopyEditorService, WorkingCopyEditorService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyEditorService';
|
|
6
6
|
import { IWorkingCopyHistoryService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyHistory';
|
|
7
|
-
import { BrowserWorkingCopyHistoryService } from 'vscode/
|
|
7
|
+
import { BrowserWorkingCopyHistoryService } from './vscode/src/vs/workbench/services/workingCopy/browser/workingCopyHistoryService.js';
|
|
8
8
|
import getServiceOverride$1 from '@codingame/monaco-vscode-files-service-override';
|
|
9
9
|
|
|
10
10
|
function getServiceOverride() {
|