diff --git a/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts b/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts index ae6d065e5f1f1..7515f8a1001a7 100644 --- a/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts +++ b/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts @@ -198,14 +198,14 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo } }, { - label: localize('accept local', "Accept Local"), + label: localize('accept merges', "Accept Merges"), run: () => { this.telemetryService.publicLog2<{ source: string, action: string }, SyncConflictsClassification>('sync/handleConflicts', { source: syncResource, action: 'acceptLocal' }); this.acceptLocal(syncResource, conflicts); } }, { - label: localize('show conflicts', "Show Conflicts"), + label: localize('show merges', "Show Merges"), run: () => { this.telemetryService.publicLog2<{ source: string, action?: string }, SyncConflictsClassification>('sync/showConflicts', { source: syncResource }); this.handleConflicts([syncResource, conflicts]); @@ -651,18 +651,12 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo private async handleConflicts([syncResource, conflicts]: [SyncResource, IResourcePreview[]]): Promise { for (const conflict of conflicts) { - let label: string | undefined = undefined; - if (syncResource === SyncResource.Settings) { - label = localize('settings conflicts preview', "Settings Conflicts (Remote ↔ Local)"); - } else if (syncResource === SyncResource.Keybindings) { - label = localize('keybindings conflicts preview', "Keybindings Conflicts (Remote ↔ Local)"); - } else if (syncResource === SyncResource.Snippets) { - label = localize('snippets conflicts preview', "User Snippet Conflicts (Remote ↔ Local) - {0}", basename(conflict.previewResource)); - } + const leftResourceName = localize({ key: 'leftResourceName', comment: ['remote as in file in cloud'] }, "{0} (Remote)", basename(conflict.remoteResource)); + const rightResourceName = localize('merges', "{0} (Merges)", basename(conflict.previewResource)); await this.editorService.openEditor({ leftResource: conflict.remoteResource, rightResource: conflict.previewResource, - label, + label: localize('sideBySideLabels', "{0} ↔ {1}", leftResourceName, rightResourceName), options: { preserveFocus: false, pinned: true, @@ -1127,7 +1121,6 @@ class AcceptChangesContribution extends Disposable implements IEditorContributio @IInstantiationService private readonly instantiationService: IInstantiationService, @IUserDataSyncService private readonly userDataSyncService: IUserDataSyncService, @INotificationService private readonly notificationService: INotificationService, - @IDialogService private readonly dialogService: IDialogService, @IConfigurationService private readonly configurationService: IConfigurationService, @ITelemetryService private readonly telemetryService: ITelemetryService, @IUserDataAutoSyncService private readonly userDataAutoSyncService: IUserDataAutoSyncService, @@ -1185,35 +1178,22 @@ class AcceptChangesContribution extends Disposable implements IEditorContributio const [syncResource, conflicts] = this.getSyncResourceConflicts(resource)!; const isRemote = conflicts.some(({ remoteResource }) => isEqual(remoteResource, resource)); const acceptRemoteLabel = localize('accept remote', "Accept Remote"); - const acceptLocalLabel = localize('accept merge preview', "Accept Merge Preview"); - this.acceptChangesButton = this.instantiationService.createInstance(FloatingClickWidget, this.editor, isRemote ? acceptRemoteLabel : acceptLocalLabel, null); + const acceptMergesLabel = localize('accept merges', "Accept Merges"); + this.acceptChangesButton = this.instantiationService.createInstance(FloatingClickWidget, this.editor, isRemote ? acceptRemoteLabel : acceptMergesLabel, null); this._register(this.acceptChangesButton.onClick(async () => { const model = this.editor.getModel(); if (model) { this.telemetryService.publicLog2<{ source: string, action: string }, SyncConflictsClassification>('sync/handleConflicts', { source: syncResource, action: isRemote ? 'acceptRemote' : 'acceptLocal' }); - const syncAreaLabel = getSyncAreaLabel(syncResource); - const result = await this.dialogService.confirm({ - type: 'info', - title: isRemote - ? localize('Sync accept remote', "Preferences Sync: {0}", acceptRemoteLabel) - : localize('Sync accept local', "Preferences Sync: {0}", acceptLocalLabel), - message: isRemote - ? localize('confirm replace and overwrite local', "Would you like to accept remote {0} and replace local {1}?", syncAreaLabel.toLowerCase(), syncAreaLabel.toLowerCase()) - : localize('confirm replace and overwrite remote', "Would you like to accept local {0} and replace remote {1}?", syncAreaLabel.toLowerCase(), syncAreaLabel.toLowerCase()), - primaryButton: isRemote ? acceptRemoteLabel : acceptLocalLabel - }); - if (result.confirmed) { - try { - await this.userDataSyncService.accept(syncResource, model.uri, model.getValue(), true); - } catch (e) { - if (e instanceof UserDataSyncError && e.code === UserDataSyncErrorCode.LocalPreconditionFailed) { - const syncResourceCoflicts = this.userDataSyncService.conflicts.filter(syncResourceCoflicts => syncResourceCoflicts[0] === syncResource)[0]; - if (syncResourceCoflicts && conflicts.some(conflict => isEqual(conflict.previewResource, model.uri) || isEqual(conflict.remoteResource, model.uri))) { - this.notificationService.warn(localize('update conflicts', "Could not resolve conflicts as there is new local version available. Please try again.")); - } - } else { - this.notificationService.error(e); + try { + await this.userDataSyncService.accept(syncResource, model.uri, model.getValue(), true); + } catch (e) { + if (e instanceof UserDataSyncError && e.code === UserDataSyncErrorCode.LocalPreconditionFailed) { + const syncResourceCoflicts = this.userDataSyncService.conflicts.filter(syncResourceCoflicts => syncResourceCoflicts[0] === syncResource)[0]; + if (syncResourceCoflicts && conflicts.some(conflict => isEqual(conflict.previewResource, model.uri) || isEqual(conflict.remoteResource, model.uri))) { + this.notificationService.warn(localize('update conflicts', "Could not resolve conflicts as there is new local version available. Please try again.")); } + } else { + this.notificationService.error(e); } } }