@codingame/monaco-vscode-timeline-service-override 25.1.2 → 26.0.1
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 +2 -2
- package/vscode/src/vs/workbench/contrib/localHistory/browser/localHistory.js +11 -5
- package/vscode/src/vs/workbench/contrib/localHistory/browser/localHistoryCommands.js +178 -94
- package/vscode/src/vs/workbench/contrib/localHistory/browser/localHistoryFileSystemProvider.js +33 -15
- package/vscode/src/vs/workbench/contrib/localHistory/browser/localHistoryTimeline.js +49 -30
- package/vscode/src/vs/workbench/contrib/timeline/browser/timeline.contribution.js +24 -22
- package/vscode/src/vs/workbench/contrib/timeline/browser/timelinePane.js +315 -247
- package/vscode/src/vs/workbench/contrib/timeline/common/timelineService.js +30 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-timeline-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "26.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - timeline service-override",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@codingame/monaco-vscode-api": "
|
|
18
|
+
"@codingame/monaco-vscode-api": "26.0.1"
|
|
19
19
|
},
|
|
20
20
|
"main": "index.js",
|
|
21
21
|
"module": "index.js",
|
|
@@ -9,7 +9,13 @@ import { safeIntl } from '@codingame/monaco-vscode-api/vscode/vs/base/common/dat
|
|
|
9
9
|
let localHistoryDateFormatter = undefined;
|
|
10
10
|
function getLocalHistoryDateFormatter() {
|
|
11
11
|
if (!localHistoryDateFormatter) {
|
|
12
|
-
const options = {
|
|
12
|
+
const options = {
|
|
13
|
+
year: "numeric",
|
|
14
|
+
month: "long",
|
|
15
|
+
day: "numeric",
|
|
16
|
+
hour: "numeric",
|
|
17
|
+
minute: "numeric"
|
|
18
|
+
};
|
|
13
19
|
const formatter = safeIntl.DateTimeFormat(language, options).value;
|
|
14
20
|
localHistoryDateFormatter = {
|
|
15
21
|
format: date => formatter.format(date)
|
|
@@ -17,9 +23,9 @@ function getLocalHistoryDateFormatter() {
|
|
|
17
23
|
}
|
|
18
24
|
return localHistoryDateFormatter;
|
|
19
25
|
}
|
|
20
|
-
const LOCAL_HISTORY_MENU_CONTEXT_VALUE =
|
|
21
|
-
const LOCAL_HISTORY_MENU_CONTEXT_KEY = ( ContextKeyExpr.equals(
|
|
22
|
-
const LOCAL_HISTORY_ICON_ENTRY = registerIcon(
|
|
23
|
-
const LOCAL_HISTORY_ICON_RESTORE = registerIcon(
|
|
26
|
+
const LOCAL_HISTORY_MENU_CONTEXT_VALUE = "localHistory:item";
|
|
27
|
+
const LOCAL_HISTORY_MENU_CONTEXT_KEY = ( ContextKeyExpr.equals("timelineItem", LOCAL_HISTORY_MENU_CONTEXT_VALUE));
|
|
28
|
+
const LOCAL_HISTORY_ICON_ENTRY = registerIcon("localHistory-icon", Codicon.circleOutline, ( localize(8838, "Icon for a local history entry in the timeline view.")));
|
|
29
|
+
const LOCAL_HISTORY_ICON_RESTORE = registerIcon("localHistory-restore", Codicon.check, ( localize(8839, "Icon for restoring contents of a local history entry.")));
|
|
24
30
|
|
|
25
31
|
export { LOCAL_HISTORY_ICON_ENTRY, LOCAL_HISTORY_ICON_RESTORE, LOCAL_HISTORY_MENU_CONTEXT_KEY, LOCAL_HISTORY_MENU_CONTEXT_VALUE, getLocalHistoryDateFormatter };
|
|
@@ -31,17 +31,17 @@ import { ResourceSet } from '@codingame/monaco-vscode-api/vscode/vs/base/common/
|
|
|
31
31
|
import { IHistoryService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/history/common/history.service';
|
|
32
32
|
import { DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
33
33
|
|
|
34
|
-
const LOCAL_HISTORY_CATEGORY = ( localize2(
|
|
35
|
-
const CTX_LOCAL_HISTORY_ENABLED = ( ContextKeyExpr.has(
|
|
36
|
-
const COMPARE_WITH_FILE_LABEL = ( localize2(
|
|
34
|
+
const LOCAL_HISTORY_CATEGORY = ( localize2(8840, "Local History"));
|
|
35
|
+
const CTX_LOCAL_HISTORY_ENABLED = ( ContextKeyExpr.has("config.workbench.localHistory.enabled"));
|
|
36
|
+
const COMPARE_WITH_FILE_LABEL = ( localize2(8841, "Compare with File"));
|
|
37
37
|
registerAction2(class extends Action2 {
|
|
38
38
|
constructor() {
|
|
39
39
|
super({
|
|
40
|
-
id:
|
|
40
|
+
id: "workbench.action.localHistory.compareWithFile",
|
|
41
41
|
title: COMPARE_WITH_FILE_LABEL,
|
|
42
42
|
menu: {
|
|
43
43
|
id: MenuId.TimelineItemContext,
|
|
44
|
-
group:
|
|
44
|
+
group: "1_compare",
|
|
45
45
|
order: 1,
|
|
46
46
|
when: LOCAL_HISTORY_MENU_CONTEXT_KEY
|
|
47
47
|
}
|
|
@@ -50,20 +50,25 @@ registerAction2(class extends Action2 {
|
|
|
50
50
|
async run(accessor, item) {
|
|
51
51
|
const commandService = accessor.get(ICommandService);
|
|
52
52
|
const workingCopyHistoryService = accessor.get(IWorkingCopyHistoryService);
|
|
53
|
-
const {
|
|
53
|
+
const {
|
|
54
|
+
entry
|
|
55
|
+
} = await findLocalHistoryEntry(workingCopyHistoryService, item);
|
|
54
56
|
if (entry) {
|
|
55
|
-
return commandService.executeCommand(
|
|
57
|
+
return commandService.executeCommand(
|
|
58
|
+
API_OPEN_DIFF_EDITOR_COMMAND_ID,
|
|
59
|
+
...toDiffEditorArguments(entry, entry.workingCopy.resource)
|
|
60
|
+
);
|
|
56
61
|
}
|
|
57
62
|
}
|
|
58
63
|
});
|
|
59
64
|
registerAction2(class extends Action2 {
|
|
60
65
|
constructor() {
|
|
61
66
|
super({
|
|
62
|
-
id:
|
|
63
|
-
title: ( localize2(
|
|
67
|
+
id: "workbench.action.localHistory.compareWithPrevious",
|
|
68
|
+
title: ( localize2(8842, "Compare with Previous")),
|
|
64
69
|
menu: {
|
|
65
70
|
id: MenuId.TimelineItemContext,
|
|
66
|
-
group:
|
|
71
|
+
group: "1_compare",
|
|
67
72
|
order: 2,
|
|
68
73
|
when: LOCAL_HISTORY_MENU_CONTEXT_KEY
|
|
69
74
|
}
|
|
@@ -73,7 +78,10 @@ registerAction2(class extends Action2 {
|
|
|
73
78
|
const commandService = accessor.get(ICommandService);
|
|
74
79
|
const workingCopyHistoryService = accessor.get(IWorkingCopyHistoryService);
|
|
75
80
|
const editorService = accessor.get(IEditorService);
|
|
76
|
-
const {
|
|
81
|
+
const {
|
|
82
|
+
entry,
|
|
83
|
+
previous
|
|
84
|
+
} = await findLocalHistoryEntry(workingCopyHistoryService, item);
|
|
77
85
|
if (entry) {
|
|
78
86
|
if (!previous) {
|
|
79
87
|
return openEntry(entry, editorService);
|
|
@@ -83,15 +91,15 @@ registerAction2(class extends Action2 {
|
|
|
83
91
|
}
|
|
84
92
|
});
|
|
85
93
|
let itemSelectedForCompare = undefined;
|
|
86
|
-
const LocalHistoryItemSelectedForCompare = ( new RawContextKey(
|
|
94
|
+
const LocalHistoryItemSelectedForCompare = ( new RawContextKey("localHistoryItemSelectedForCompare", false, true));
|
|
87
95
|
registerAction2(class extends Action2 {
|
|
88
96
|
constructor() {
|
|
89
97
|
super({
|
|
90
|
-
id:
|
|
91
|
-
title: ( localize2(
|
|
98
|
+
id: "workbench.action.localHistory.selectForCompare",
|
|
99
|
+
title: ( localize2(8843, "Select for Compare")),
|
|
92
100
|
menu: {
|
|
93
101
|
id: MenuId.TimelineItemContext,
|
|
94
|
-
group:
|
|
102
|
+
group: "2_compare_with",
|
|
95
103
|
order: 2,
|
|
96
104
|
when: LOCAL_HISTORY_MENU_CONTEXT_KEY
|
|
97
105
|
}
|
|
@@ -100,7 +108,9 @@ registerAction2(class extends Action2 {
|
|
|
100
108
|
async run(accessor, item) {
|
|
101
109
|
const workingCopyHistoryService = accessor.get(IWorkingCopyHistoryService);
|
|
102
110
|
const contextKeyService = accessor.get(IContextKeyService);
|
|
103
|
-
const {
|
|
111
|
+
const {
|
|
112
|
+
entry
|
|
113
|
+
} = await findLocalHistoryEntry(workingCopyHistoryService, item);
|
|
104
114
|
if (entry) {
|
|
105
115
|
itemSelectedForCompare = item;
|
|
106
116
|
LocalHistoryItemSelectedForCompare.bindTo(contextKeyService).set(true);
|
|
@@ -110,11 +120,11 @@ registerAction2(class extends Action2 {
|
|
|
110
120
|
registerAction2(class extends Action2 {
|
|
111
121
|
constructor() {
|
|
112
122
|
super({
|
|
113
|
-
id:
|
|
114
|
-
title: ( localize2(
|
|
123
|
+
id: "workbench.action.localHistory.compareWithSelected",
|
|
124
|
+
title: ( localize2(8844, "Compare with Selected")),
|
|
115
125
|
menu: {
|
|
116
126
|
id: MenuId.TimelineItemContext,
|
|
117
|
-
group:
|
|
127
|
+
group: "2_compare_with",
|
|
118
128
|
order: 1,
|
|
119
129
|
when: ( ContextKeyExpr.and(LOCAL_HISTORY_MENU_CONTEXT_KEY, LocalHistoryItemSelectedForCompare))
|
|
120
130
|
}
|
|
@@ -130,20 +140,25 @@ registerAction2(class extends Action2 {
|
|
|
130
140
|
if (!selectedEntry) {
|
|
131
141
|
return;
|
|
132
142
|
}
|
|
133
|
-
const {
|
|
143
|
+
const {
|
|
144
|
+
entry
|
|
145
|
+
} = await findLocalHistoryEntry(workingCopyHistoryService, item);
|
|
134
146
|
if (entry) {
|
|
135
|
-
return commandService.executeCommand(
|
|
147
|
+
return commandService.executeCommand(
|
|
148
|
+
API_OPEN_DIFF_EDITOR_COMMAND_ID,
|
|
149
|
+
...toDiffEditorArguments(selectedEntry, entry)
|
|
150
|
+
);
|
|
136
151
|
}
|
|
137
152
|
}
|
|
138
153
|
});
|
|
139
154
|
registerAction2(class extends Action2 {
|
|
140
155
|
constructor() {
|
|
141
156
|
super({
|
|
142
|
-
id:
|
|
143
|
-
title: ( localize2(
|
|
157
|
+
id: "workbench.action.localHistory.open",
|
|
158
|
+
title: ( localize2(8845, "Show Contents")),
|
|
144
159
|
menu: {
|
|
145
160
|
id: MenuId.TimelineItemContext,
|
|
146
|
-
group:
|
|
161
|
+
group: "3_contents",
|
|
147
162
|
order: 1,
|
|
148
163
|
when: LOCAL_HISTORY_MENU_CONTEXT_KEY
|
|
149
164
|
}
|
|
@@ -152,21 +167,23 @@ registerAction2(class extends Action2 {
|
|
|
152
167
|
async run(accessor, item) {
|
|
153
168
|
const workingCopyHistoryService = accessor.get(IWorkingCopyHistoryService);
|
|
154
169
|
const editorService = accessor.get(IEditorService);
|
|
155
|
-
const {
|
|
170
|
+
const {
|
|
171
|
+
entry
|
|
172
|
+
} = await findLocalHistoryEntry(workingCopyHistoryService, item);
|
|
156
173
|
if (entry) {
|
|
157
174
|
return openEntry(entry, editorService);
|
|
158
175
|
}
|
|
159
176
|
}
|
|
160
177
|
});
|
|
161
|
-
const RESTORE_CONTENTS_LABEL = ( localize2(
|
|
178
|
+
const RESTORE_CONTENTS_LABEL = ( localize2(8846, "Restore Contents"));
|
|
162
179
|
registerAction2(class extends Action2 {
|
|
163
180
|
constructor() {
|
|
164
181
|
super({
|
|
165
|
-
id:
|
|
182
|
+
id: "workbench.action.localHistory.restoreViaEditor",
|
|
166
183
|
title: RESTORE_CONTENTS_LABEL,
|
|
167
184
|
menu: {
|
|
168
185
|
id: MenuId.EditorTitle,
|
|
169
|
-
group:
|
|
186
|
+
group: "navigation",
|
|
170
187
|
order: -10,
|
|
171
188
|
when: ( ResourceContextKey.Scheme.isEqualTo(LocalHistoryFileSystemProvider.SCHEMA))
|
|
172
189
|
},
|
|
@@ -174,18 +191,24 @@ registerAction2(class extends Action2 {
|
|
|
174
191
|
});
|
|
175
192
|
}
|
|
176
193
|
async run(accessor, uri) {
|
|
177
|
-
const {
|
|
178
|
-
|
|
194
|
+
const {
|
|
195
|
+
associatedResource,
|
|
196
|
+
location
|
|
197
|
+
} = LocalHistoryFileSystemProvider.fromLocalHistoryFileSystem(uri);
|
|
198
|
+
return restore(accessor, {
|
|
199
|
+
uri: associatedResource,
|
|
200
|
+
handle: basenameOrAuthority(location)
|
|
201
|
+
});
|
|
179
202
|
}
|
|
180
203
|
});
|
|
181
204
|
registerAction2(class extends Action2 {
|
|
182
205
|
constructor() {
|
|
183
206
|
super({
|
|
184
|
-
id:
|
|
207
|
+
id: "workbench.action.localHistory.restore",
|
|
185
208
|
title: RESTORE_CONTENTS_LABEL,
|
|
186
209
|
menu: {
|
|
187
210
|
id: MenuId.TimelineItemContext,
|
|
188
|
-
group:
|
|
211
|
+
group: "3_contents",
|
|
189
212
|
order: 2,
|
|
190
213
|
when: LOCAL_HISTORY_MENU_CONTEXT_KEY
|
|
191
214
|
}
|
|
@@ -195,24 +218,28 @@ registerAction2(class extends Action2 {
|
|
|
195
218
|
return restore(accessor, item);
|
|
196
219
|
}
|
|
197
220
|
});
|
|
198
|
-
const restoreSaveSource = SaveSourceRegistry.registerSource(
|
|
221
|
+
const restoreSaveSource = SaveSourceRegistry.registerSource("localHistoryRestore.source", ( localize(8847, "File Restored")));
|
|
199
222
|
async function restore(accessor, item) {
|
|
200
223
|
const fileService = accessor.get(IFileService);
|
|
201
224
|
const dialogService = accessor.get(IDialogService);
|
|
202
225
|
const workingCopyService = accessor.get(IWorkingCopyService);
|
|
203
226
|
const workingCopyHistoryService = accessor.get(IWorkingCopyHistoryService);
|
|
204
227
|
const editorService = accessor.get(IEditorService);
|
|
205
|
-
const {
|
|
228
|
+
const {
|
|
229
|
+
entry
|
|
230
|
+
} = await findLocalHistoryEntry(workingCopyHistoryService, item);
|
|
206
231
|
if (entry) {
|
|
207
|
-
const {
|
|
208
|
-
|
|
232
|
+
const {
|
|
233
|
+
confirmed
|
|
234
|
+
} = await dialogService.confirm({
|
|
235
|
+
type: "warning",
|
|
209
236
|
message: ( localize(
|
|
210
|
-
|
|
237
|
+
8848,
|
|
211
238
|
"Do you want to restore the contents of '{0}'?",
|
|
212
239
|
basename(entry.workingCopy.resource)
|
|
213
240
|
)),
|
|
214
|
-
detail: ( localize(
|
|
215
|
-
primaryButton: ( localize(
|
|
241
|
+
detail: ( localize(8849, "Restoring will discard any unsaved changes.")),
|
|
242
|
+
primaryButton: ( localize(8850, "&&Restore"))
|
|
216
243
|
});
|
|
217
244
|
if (!confirmed) {
|
|
218
245
|
return;
|
|
@@ -221,23 +248,28 @@ async function restore(accessor, item) {
|
|
|
221
248
|
if (workingCopies) {
|
|
222
249
|
for (const workingCopy of workingCopies) {
|
|
223
250
|
if (workingCopy.isDirty()) {
|
|
224
|
-
await workingCopy.revert({
|
|
251
|
+
await workingCopy.revert({
|
|
252
|
+
soft: true
|
|
253
|
+
});
|
|
225
254
|
}
|
|
226
255
|
}
|
|
227
256
|
}
|
|
228
257
|
try {
|
|
229
258
|
await fileService.cloneFile(entry.location, entry.workingCopy.resource);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
await dialogService.error(( localize(8544, "Unable to restore '{0}'.", basename(entry.workingCopy.resource))), toErrorMessage(error));
|
|
259
|
+
} catch (error) {
|
|
260
|
+
await dialogService.error(( localize(8851, "Unable to restore '{0}'.", basename(entry.workingCopy.resource))), toErrorMessage(error));
|
|
233
261
|
return;
|
|
234
262
|
}
|
|
235
263
|
if (workingCopies) {
|
|
236
264
|
for (const workingCopy of workingCopies) {
|
|
237
|
-
await workingCopy.revert({
|
|
265
|
+
await workingCopy.revert({
|
|
266
|
+
force: true
|
|
267
|
+
});
|
|
238
268
|
}
|
|
239
269
|
}
|
|
240
|
-
await editorService.openEditor({
|
|
270
|
+
await editorService.openEditor({
|
|
271
|
+
resource: entry.workingCopy.resource
|
|
272
|
+
});
|
|
241
273
|
await workingCopyHistoryService.addEntry({
|
|
242
274
|
resource: entry.workingCopy.resource,
|
|
243
275
|
source: restoreSaveSource
|
|
@@ -248,8 +280,8 @@ async function restore(accessor, item) {
|
|
|
248
280
|
registerAction2(class extends Action2 {
|
|
249
281
|
constructor() {
|
|
250
282
|
super({
|
|
251
|
-
id:
|
|
252
|
-
title: ( localize2(
|
|
283
|
+
id: "workbench.action.localHistory.restoreViaPicker",
|
|
284
|
+
title: ( localize2(8852, "Find Entry to Restore")),
|
|
253
285
|
f1: true,
|
|
254
286
|
category: LOCAL_HISTORY_CATEGORY,
|
|
255
287
|
precondition: CTX_LOCAL_HISTORY_ENABLED
|
|
@@ -272,7 +304,11 @@ registerAction2(class extends Action2 {
|
|
|
272
304
|
resourcePicker.busy = true;
|
|
273
305
|
resourcePicker.show();
|
|
274
306
|
const resources = ( new ResourceSet(await workingCopyHistoryService.getAll(cts.token)));
|
|
275
|
-
const recentEditorResources = ( new ResourceSet(coalesce(( historyService.getHistory().map((
|
|
307
|
+
const recentEditorResources = ( new ResourceSet(coalesce(( historyService.getHistory().map((
|
|
308
|
+
{
|
|
309
|
+
resource
|
|
310
|
+
}
|
|
311
|
+
) => resource)))));
|
|
276
312
|
const resourcesSortedByRecency = [];
|
|
277
313
|
for (const resource of recentEditorResources) {
|
|
278
314
|
if (( resources.has(resource))) {
|
|
@@ -282,13 +318,15 @@ registerAction2(class extends Action2 {
|
|
|
282
318
|
}
|
|
283
319
|
resourcesSortedByRecency.push(...[...resources].sort((r1, r2) => r1.fsPath < r2.fsPath ? -1 : 1));
|
|
284
320
|
resourcePicker.busy = false;
|
|
285
|
-
resourcePicker.placeholder = ( localize(
|
|
321
|
+
resourcePicker.placeholder = ( localize(8853, "Select the file to show local history for"));
|
|
286
322
|
resourcePicker.matchOnLabel = true;
|
|
287
323
|
resourcePicker.matchOnDescription = true;
|
|
288
324
|
resourcePicker.items = ( [...resourcesSortedByRecency].map(resource => ({
|
|
289
325
|
resource,
|
|
290
326
|
label: basenameOrAuthority(resource),
|
|
291
|
-
description: labelService.getUriLabel(dirname(resource), {
|
|
327
|
+
description: labelService.getUriLabel(dirname(resource), {
|
|
328
|
+
relative: true
|
|
329
|
+
}),
|
|
292
330
|
iconClasses: getIconClasses(modelService, languageService, resource)
|
|
293
331
|
})));
|
|
294
332
|
await Event.toPromise(resourcePicker.onDidAccept);
|
|
@@ -306,7 +344,7 @@ registerAction2(class extends Action2 {
|
|
|
306
344
|
const entries = await workingCopyHistoryService.getEntries(resource, cts.token);
|
|
307
345
|
entryPicker.busy = false;
|
|
308
346
|
entryPicker.canAcceptInBackground = true;
|
|
309
|
-
entryPicker.placeholder = ( localize(
|
|
347
|
+
entryPicker.placeholder = ( localize(8854, "Select the local history entry to open"));
|
|
310
348
|
entryPicker.matchOnLabel = true;
|
|
311
349
|
entryPicker.matchOnDescription = true;
|
|
312
350
|
entryPicker.items = ( Array.from(entries).reverse().map(entry => ({
|
|
@@ -314,7 +352,7 @@ registerAction2(class extends Action2 {
|
|
|
314
352
|
label: `$(circle-outline) ${SaveSourceRegistry.getSourceLabel(entry.source)}`,
|
|
315
353
|
description: toLocalHistoryEntryDateLabel(entry.timestamp)
|
|
316
354
|
})));
|
|
317
|
-
entryPickerDisposables.add(entryPicker.onDidAccept(async
|
|
355
|
+
entryPickerDisposables.add(entryPicker.onDidAccept(async e => {
|
|
318
356
|
if (!e.inBackground) {
|
|
319
357
|
entryPickerDisposables.dispose();
|
|
320
358
|
}
|
|
@@ -324,21 +362,36 @@ registerAction2(class extends Action2 {
|
|
|
324
362
|
}
|
|
325
363
|
const resourceExists = await fileService.exists(selectedItem.entry.workingCopy.resource);
|
|
326
364
|
if (resourceExists) {
|
|
327
|
-
return commandService.executeCommand(
|
|
365
|
+
return commandService.executeCommand(
|
|
366
|
+
API_OPEN_DIFF_EDITOR_COMMAND_ID,
|
|
367
|
+
...toDiffEditorArguments(selectedItem.entry, selectedItem.entry.workingCopy.resource, {
|
|
368
|
+
preserveFocus: e.inBackground
|
|
369
|
+
})
|
|
370
|
+
);
|
|
328
371
|
}
|
|
329
|
-
return openEntry(selectedItem.entry, editorService, {
|
|
372
|
+
return openEntry(selectedItem.entry, editorService, {
|
|
373
|
+
preserveFocus: e.inBackground
|
|
374
|
+
});
|
|
330
375
|
}));
|
|
331
376
|
}
|
|
332
377
|
});
|
|
333
|
-
MenuRegistry.appendMenuItem(MenuId.TimelineTitle, {
|
|
378
|
+
MenuRegistry.appendMenuItem(MenuId.TimelineTitle, {
|
|
379
|
+
command: {
|
|
380
|
+
id: "workbench.action.localHistory.restoreViaPicker",
|
|
381
|
+
title: ( localize2(8855, "Local History: Find Entry to Restore..."))
|
|
382
|
+
},
|
|
383
|
+
group: "submenu",
|
|
384
|
+
order: 1,
|
|
385
|
+
when: CTX_LOCAL_HISTORY_ENABLED
|
|
386
|
+
});
|
|
334
387
|
registerAction2(class extends Action2 {
|
|
335
388
|
constructor() {
|
|
336
389
|
super({
|
|
337
|
-
id:
|
|
338
|
-
title: ( localize2(
|
|
390
|
+
id: "workbench.action.localHistory.rename",
|
|
391
|
+
title: ( localize2(8856, "Rename")),
|
|
339
392
|
menu: {
|
|
340
393
|
id: MenuId.TimelineItemContext,
|
|
341
|
-
group:
|
|
394
|
+
group: "5_edit",
|
|
342
395
|
order: 1,
|
|
343
396
|
when: LOCAL_HISTORY_MENU_CONTEXT_KEY
|
|
344
397
|
}
|
|
@@ -347,18 +400,22 @@ registerAction2(class extends Action2 {
|
|
|
347
400
|
async run(accessor, item) {
|
|
348
401
|
const workingCopyHistoryService = accessor.get(IWorkingCopyHistoryService);
|
|
349
402
|
const quickInputService = accessor.get(IQuickInputService);
|
|
350
|
-
const {
|
|
403
|
+
const {
|
|
404
|
+
entry
|
|
405
|
+
} = await findLocalHistoryEntry(workingCopyHistoryService, item);
|
|
351
406
|
if (entry) {
|
|
352
407
|
const disposables = ( new DisposableStore());
|
|
353
408
|
const inputBox = disposables.add(quickInputService.createInputBox());
|
|
354
|
-
inputBox.title = ( localize(
|
|
409
|
+
inputBox.title = ( localize(8857, "Rename Local History Entry"));
|
|
355
410
|
inputBox.ignoreFocusOut = true;
|
|
356
|
-
inputBox.placeholder = ( localize(
|
|
411
|
+
inputBox.placeholder = ( localize(8858, "Enter the new name of the local history entry"));
|
|
357
412
|
inputBox.value = SaveSourceRegistry.getSourceLabel(entry.source);
|
|
358
413
|
inputBox.show();
|
|
359
414
|
disposables.add(inputBox.onDidAccept(() => {
|
|
360
415
|
if (inputBox.value) {
|
|
361
|
-
workingCopyHistoryService.updateEntry(entry, {
|
|
416
|
+
workingCopyHistoryService.updateEntry(entry, {
|
|
417
|
+
source: inputBox.value
|
|
418
|
+
}, CancellationToken.None);
|
|
362
419
|
}
|
|
363
420
|
disposables.dispose();
|
|
364
421
|
}));
|
|
@@ -368,11 +425,11 @@ registerAction2(class extends Action2 {
|
|
|
368
425
|
registerAction2(class extends Action2 {
|
|
369
426
|
constructor() {
|
|
370
427
|
super({
|
|
371
|
-
id:
|
|
372
|
-
title: ( localize2(
|
|
428
|
+
id: "workbench.action.localHistory.delete",
|
|
429
|
+
title: ( localize2(8859, "Delete")),
|
|
373
430
|
menu: {
|
|
374
431
|
id: MenuId.TimelineItemContext,
|
|
375
|
-
group:
|
|
432
|
+
group: "5_edit",
|
|
376
433
|
order: 2,
|
|
377
434
|
when: LOCAL_HISTORY_MENU_CONTEXT_KEY
|
|
378
435
|
}
|
|
@@ -382,18 +439,22 @@ registerAction2(class extends Action2 {
|
|
|
382
439
|
const workingCopyHistoryService = accessor.get(IWorkingCopyHistoryService);
|
|
383
440
|
const editorService = accessor.get(IEditorService);
|
|
384
441
|
const dialogService = accessor.get(IDialogService);
|
|
385
|
-
const {
|
|
442
|
+
const {
|
|
443
|
+
entry
|
|
444
|
+
} = await findLocalHistoryEntry(workingCopyHistoryService, item);
|
|
386
445
|
if (entry) {
|
|
387
|
-
const {
|
|
388
|
-
|
|
446
|
+
const {
|
|
447
|
+
confirmed
|
|
448
|
+
} = await dialogService.confirm({
|
|
449
|
+
type: "warning",
|
|
389
450
|
message: ( localize(
|
|
390
|
-
|
|
451
|
+
8860,
|
|
391
452
|
"Do you want to delete the local history entry of '{0}' from {1}?",
|
|
392
453
|
entry.workingCopy.name,
|
|
393
454
|
toLocalHistoryEntryDateLabel(entry.timestamp)
|
|
394
455
|
)),
|
|
395
|
-
detail: ( localize(
|
|
396
|
-
primaryButton: ( localize(
|
|
456
|
+
detail: ( localize(8861, "This action is irreversible!")),
|
|
457
|
+
primaryButton: ( localize(8862, "&&Delete"))
|
|
397
458
|
});
|
|
398
459
|
if (!confirmed) {
|
|
399
460
|
return;
|
|
@@ -406,8 +467,8 @@ registerAction2(class extends Action2 {
|
|
|
406
467
|
registerAction2(class extends Action2 {
|
|
407
468
|
constructor() {
|
|
408
469
|
super({
|
|
409
|
-
id:
|
|
410
|
-
title: ( localize2(
|
|
470
|
+
id: "workbench.action.localHistory.deleteAll",
|
|
471
|
+
title: ( localize2(8863, "Delete All")),
|
|
411
472
|
f1: true,
|
|
412
473
|
category: LOCAL_HISTORY_CATEGORY,
|
|
413
474
|
precondition: CTX_LOCAL_HISTORY_ENABLED
|
|
@@ -416,11 +477,13 @@ registerAction2(class extends Action2 {
|
|
|
416
477
|
async run(accessor) {
|
|
417
478
|
const dialogService = accessor.get(IDialogService);
|
|
418
479
|
const workingCopyHistoryService = accessor.get(IWorkingCopyHistoryService);
|
|
419
|
-
const {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
480
|
+
const {
|
|
481
|
+
confirmed
|
|
482
|
+
} = await dialogService.confirm({
|
|
483
|
+
type: "warning",
|
|
484
|
+
message: ( localize(8864, "Do you want to delete all entries of all files in local history?")),
|
|
485
|
+
detail: ( localize(8865, "This action is irreversible!")),
|
|
486
|
+
primaryButton: ( localize(8866, "&&Delete All"))
|
|
424
487
|
});
|
|
425
488
|
if (!confirmed) {
|
|
426
489
|
return;
|
|
@@ -431,8 +494,8 @@ registerAction2(class extends Action2 {
|
|
|
431
494
|
registerAction2(class extends Action2 {
|
|
432
495
|
constructor() {
|
|
433
496
|
super({
|
|
434
|
-
id:
|
|
435
|
-
title: ( localize2(
|
|
497
|
+
id: "workbench.action.localHistory.create",
|
|
498
|
+
title: ( localize2(8867, "Create Entry")),
|
|
436
499
|
f1: true,
|
|
437
500
|
category: LOCAL_HISTORY_CATEGORY,
|
|
438
501
|
precondition: ( ContextKeyExpr.and(CTX_LOCAL_HISTORY_ENABLED, ActiveEditorContext))
|
|
@@ -444,16 +507,18 @@ registerAction2(class extends Action2 {
|
|
|
444
507
|
const editorService = accessor.get(IEditorService);
|
|
445
508
|
const labelService = accessor.get(ILabelService);
|
|
446
509
|
const pathService = accessor.get(IPathService);
|
|
447
|
-
const resource = EditorResourceAccessor.getOriginalUri(editorService.activeEditor, {
|
|
510
|
+
const resource = EditorResourceAccessor.getOriginalUri(editorService.activeEditor, {
|
|
511
|
+
supportSideBySide: SideBySideEditor.PRIMARY
|
|
512
|
+
});
|
|
448
513
|
if (resource?.scheme !== pathService.defaultUriScheme && resource?.scheme !== Schemas.vscodeUserData) {
|
|
449
514
|
return;
|
|
450
515
|
}
|
|
451
516
|
const disposables = ( new DisposableStore());
|
|
452
517
|
const inputBox = disposables.add(quickInputService.createInputBox());
|
|
453
|
-
inputBox.title = ( localize(
|
|
518
|
+
inputBox.title = ( localize(8868, "Create Local History Entry"));
|
|
454
519
|
inputBox.ignoreFocusOut = true;
|
|
455
520
|
inputBox.placeholder = ( localize(
|
|
456
|
-
|
|
521
|
+
8869,
|
|
457
522
|
"Enter the new name of the local history entry for '{0}'",
|
|
458
523
|
labelService.getUriBasenameLabel(resource)
|
|
459
524
|
));
|
|
@@ -462,17 +527,23 @@ registerAction2(class extends Action2 {
|
|
|
462
527
|
const entrySource = inputBox.value;
|
|
463
528
|
disposables.dispose();
|
|
464
529
|
if (entrySource) {
|
|
465
|
-
await workingCopyHistoryService.addEntry({
|
|
530
|
+
await workingCopyHistoryService.addEntry({
|
|
531
|
+
resource,
|
|
532
|
+
source: inputBox.value
|
|
533
|
+
}, CancellationToken.None);
|
|
466
534
|
}
|
|
467
535
|
}));
|
|
468
536
|
}
|
|
469
537
|
});
|
|
470
538
|
async function openEntry(entry, editorService, options) {
|
|
471
|
-
const resource = LocalHistoryFileSystemProvider.toLocalHistoryFileSystem({
|
|
539
|
+
const resource = LocalHistoryFileSystemProvider.toLocalHistoryFileSystem({
|
|
540
|
+
location: entry.location,
|
|
541
|
+
associatedResource: entry.workingCopy.resource
|
|
542
|
+
});
|
|
472
543
|
await editorService.openEditor({
|
|
473
544
|
resource,
|
|
474
545
|
label: ( localize(
|
|
475
|
-
|
|
546
|
+
8870,
|
|
476
547
|
"{0} ({1} • {2})",
|
|
477
548
|
entry.workingCopy.name,
|
|
478
549
|
SaveSourceRegistry.getSourceLabel(entry.source),
|
|
@@ -482,19 +553,29 @@ async function openEntry(entry, editorService, options) {
|
|
|
482
553
|
});
|
|
483
554
|
}
|
|
484
555
|
async function closeEntry(entry, editorService) {
|
|
485
|
-
const resource = LocalHistoryFileSystemProvider.toLocalHistoryFileSystem({
|
|
486
|
-
|
|
487
|
-
|
|
556
|
+
const resource = LocalHistoryFileSystemProvider.toLocalHistoryFileSystem({
|
|
557
|
+
location: entry.location,
|
|
558
|
+
associatedResource: entry.workingCopy.resource
|
|
559
|
+
});
|
|
560
|
+
const editors = editorService.findEditors(resource, {
|
|
561
|
+
supportSideBySide: SideBySideEditor.ANY
|
|
562
|
+
});
|
|
563
|
+
await editorService.closeEditors(editors, {
|
|
564
|
+
preserveFocus: true
|
|
565
|
+
});
|
|
488
566
|
}
|
|
489
567
|
function toDiffEditorArguments(arg1, arg2, options) {
|
|
490
|
-
const originalResource = LocalHistoryFileSystemProvider.toLocalHistoryFileSystem({
|
|
568
|
+
const originalResource = LocalHistoryFileSystemProvider.toLocalHistoryFileSystem({
|
|
569
|
+
location: arg1.location,
|
|
570
|
+
associatedResource: arg1.workingCopy.resource
|
|
571
|
+
});
|
|
491
572
|
let label;
|
|
492
573
|
let modifiedResource;
|
|
493
574
|
if (URI.isUri(arg2)) {
|
|
494
575
|
const resource = arg2;
|
|
495
576
|
modifiedResource = resource;
|
|
496
577
|
label = ( localize(
|
|
497
|
-
|
|
578
|
+
8871,
|
|
498
579
|
"{0} ({1} • {2}) ↔ {3}",
|
|
499
580
|
arg1.workingCopy.name,
|
|
500
581
|
SaveSourceRegistry.getSourceLabel(arg1.source),
|
|
@@ -504,9 +585,12 @@ function toDiffEditorArguments(arg1, arg2, options) {
|
|
|
504
585
|
}
|
|
505
586
|
else {
|
|
506
587
|
const modified = arg2;
|
|
507
|
-
modifiedResource = LocalHistoryFileSystemProvider.toLocalHistoryFileSystem({
|
|
588
|
+
modifiedResource = LocalHistoryFileSystemProvider.toLocalHistoryFileSystem({
|
|
589
|
+
location: modified.location,
|
|
590
|
+
associatedResource: modified.workingCopy.resource
|
|
591
|
+
});
|
|
508
592
|
label = ( localize(
|
|
509
|
-
|
|
593
|
+
8872,
|
|
510
594
|
"{0} ({1} • {2}) ↔ {3} ({4} • {5})",
|
|
511
595
|
arg1.workingCopy.name,
|
|
512
596
|
SaveSourceRegistry.getSourceLabel(arg1.source),
|
|
@@ -542,7 +626,7 @@ async function findLocalHistoryEntry(workingCopyHistoryService, descriptor) {
|
|
|
542
626
|
}
|
|
543
627
|
const SEP = /\//g;
|
|
544
628
|
function toLocalHistoryEntryDateLabel(timestamp) {
|
|
545
|
-
return `${getLocalHistoryDateFormatter().format(timestamp).replace(SEP,
|
|
629
|
+
return `${getLocalHistoryDateFormatter().format(timestamp).replace(SEP, "-")}`;
|
|
546
630
|
}
|
|
547
631
|
|
|
548
632
|
export { COMPARE_WITH_FILE_LABEL, findLocalHistoryEntry, toDiffEditorArguments };
|