history - tweak editor labels

This commit is contained in:
Benjamin Pasero
2022-03-16 08:54:04 +01:00
parent 1ef85dcb55
commit 4b5350f96b
3 changed files with 11 additions and 16 deletions
+2 -2
View File
@@ -574,8 +574,8 @@ class SaveSourceFactory {
return sourceDescriptor.source;
}
getSourceLabel(source: SaveSource): string | undefined {
return this.mapIdToSaveSource.get(source)?.label;
getSourceLabel(source: SaveSource): string {
return this.mapIdToSaveSource.get(source)?.label ?? source;
}
}
@@ -98,8 +98,7 @@ registerAction2(class extends Action2 {
async function openEntry(entry: IWorkingCopyHistoryEntry, editorService: IEditorService): Promise<void> {
await editorService.openEditor({
resource: LocalHistoryFileSystemProvider.toLocalHistoryFileSystem({ location: entry.location, associatedResource: entry.workingCopy.resource, label: entry.workingCopy.name }),
label: localize('localHistoryEditorLabel', "{0} ({1})", entry.workingCopy.name, entry.timestamp.label),
description: entry?.source ? SaveSourceRegistry.getSourceLabel(entry.source) : undefined
label: localize('localHistoryEditorLabel', "{0} ({1} {2})", entry.workingCopy.name, SaveSourceRegistry.getSourceLabel(entry.source), entry.timestamp.label)
});
}
@@ -322,7 +321,7 @@ registerAction2(class extends Action2 {
inputBox.title = localize('renameLocalHistoryEntryTitle', "Rename Local History Entry");
inputBox.ignoreFocusOut = true;
inputBox.placeholder = localize('renameLocalHistoryPlaceholder', "Enter the new name of the local history entry");
inputBox.value = SaveSourceRegistry.getSourceLabel(entry.source) ?? entry.source;
inputBox.value = SaveSourceRegistry.getSourceLabel(entry.source);
inputBox.show();
inputBox.onDidAccept(() => {
if (inputBox.value) {
@@ -424,7 +423,6 @@ export function toDiffEditorArguments(arg1: IWorkingCopyHistoryEntry, arg2: IWor
const originalResource = LocalHistoryFileSystemProvider.toLocalHistoryFileSystem({ location: arg1.location, associatedResource: arg1.workingCopy.resource, label: arg1.workingCopy.name });
let label: string;
let description = arg1?.source ? SaveSourceRegistry.getSourceLabel(arg1.source) : undefined;
// Right hand side depends on how the method was called
// and is either another working copy history entry
@@ -437,7 +435,7 @@ export function toDiffEditorArguments(arg1: IWorkingCopyHistoryEntry, arg2: IWor
const resource = arg2;
modifiedResource = resource;
label = localize('localHistoryCompareToFileEditorLabel', "{0} ({1}) ↔ {2}", arg1.workingCopy.name, arg1.timestamp.label, arg1.workingCopy.name);
label = localize('localHistoryCompareToFileEditorLabel', "{0} ({1} {2}) ↔ {3}", arg1.workingCopy.name, SaveSourceRegistry.getSourceLabel(arg1.source), arg1.timestamp.label, arg1.workingCopy.name);
}
// Compare with another entry
@@ -445,13 +443,13 @@ export function toDiffEditorArguments(arg1: IWorkingCopyHistoryEntry, arg2: IWor
const modified = arg2;
modifiedResource = LocalHistoryFileSystemProvider.toLocalHistoryFileSystem({ location: modified.location, associatedResource: modified.workingCopy.resource, label: modified.workingCopy.name });
label = localize('localHistoryCompareToPreviousEditorLabel', "{0} ({1}) ↔ {2} ({3})", arg1.workingCopy.name, arg1.timestamp.label, modified.workingCopy.name, modified.timestamp.label);
label = localize('localHistoryCompareToPreviousEditorLabel', "{0} ({1} {2}) ↔ {3} ({4} {5})", arg1.workingCopy.name, SaveSourceRegistry.getSourceLabel(arg1.source), arg1.timestamp.label, modified.workingCopy.name, SaveSourceRegistry.getSourceLabel(modified.source), modified.timestamp.label);
}
return [
originalResource,
modifiedResource,
{ label, description },
label,
undefined // important to keep order of arguments in command proper
];
}
@@ -123,11 +123,8 @@ export class LocalHistoryTimeline extends Disposable implements IWorkbenchContri
const entries = await this.workingCopyHistoryService.getEntries(resource, token);
// Convert to timeline items
for (let i = 0; i < entries.length; i++) {
const entry = entries[i];
const previousEntry: IWorkingCopyHistoryEntry | undefined = entries[i - 1];
items.push(this.toTimelineItem(entry, previousEntry));
for (const entry of entries) {
items.push(this.toTimelineItem(entry));
}
}
@@ -137,10 +134,10 @@ export class LocalHistoryTimeline extends Disposable implements IWorkbenchContri
};
}
private toTimelineItem(entry: IWorkingCopyHistoryEntry, previousEntry: IWorkingCopyHistoryEntry | undefined): TimelineItem {
private toTimelineItem(entry: IWorkingCopyHistoryEntry): TimelineItem {
return {
handle: entry.id,
label: SaveSourceRegistry.getSourceLabel(entry.source) ?? entry.source,
label: SaveSourceRegistry.getSourceLabel(entry.source),
description: entry.timestamp.label,
source: LocalHistoryTimeline.ID,
timestamp: entry.timestamp.value,