@@ -30,7 +30,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
3030import {
3131 IUserDataAutoSyncService , IUserDataSyncService , registerConfiguration ,
3232 SyncResource , SyncStatus , UserDataSyncError , UserDataSyncErrorCode , USER_DATA_SYNC_SCHEME , IUserDataSyncResourceEnablementService ,
33- SyncResourceConflicts , getSyncResourceFromLocalPreview , IResourcePreview
33+ getSyncResourceFromLocalPreview , IResourcePreview
3434} from 'vs/platform/userDataSync/common/userDataSync' ;
3535import { FloatingClickWidget } from 'vs/workbench/browser/parts/editor/editorWidgets' ;
3636import { IWorkbenchContribution } from 'vs/workbench/common/contributions' ;
@@ -155,10 +155,10 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
155155 }
156156
157157 private readonly conflictsDisposables = new Map < SyncResource , IDisposable > ( ) ;
158- private onDidChangeConflicts ( conflicts : SyncResourceConflicts [ ] ) {
158+ private onDidChangeConflicts ( conflicts : [ SyncResource , IResourcePreview [ ] ] [ ] ) {
159159 this . updateGlobalActivityBadge ( ) ;
160160 if ( conflicts . length ) {
161- const conflictsSources : SyncResource [ ] = conflicts . map ( conflict => conflict . syncResource ) ;
161+ const conflictsSources : SyncResource [ ] = conflicts . map ( ( [ syncResource ] ) => syncResource ) ;
162162 this . conflictsSources . set ( conflictsSources . join ( ',' ) ) ;
163163 if ( conflictsSources . indexOf ( SyncResource . Snippets ) !== - 1 ) {
164164 this . registerShowSnippetsConflictsAction ( ) ;
@@ -172,7 +172,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
172172 }
173173 } ) ;
174174
175- for ( const { syncResource, conflicts } of this . userDataSyncService . conflicts ) {
175+ for ( const [ syncResource , conflicts ] of this . userDataSyncService . conflicts ) {
176176 const conflictsEditorInputs = this . getConflictsEditorInputs ( syncResource ) ;
177177
178178 // close stale conflicts editor previews
@@ -207,7 +207,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
207207 label : localize ( 'show conflicts' , "Show Conflicts" ) ,
208208 run : ( ) => {
209209 this . telemetryService . publicLog2 < { source : string , action ?: string } , SyncConflictsClassification > ( 'sync/showConflicts' , { source : syncResource } ) ;
210- this . handleConflicts ( { syncResource, conflicts } ) ;
210+ this . handleConflicts ( [ syncResource , conflicts ] ) ;
211211 }
212212 }
213213 ] ,
@@ -376,7 +376,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
376376 let priority : number | undefined = undefined ;
377377
378378 if ( this . userDataSyncService . conflicts . length ) {
379- badge = new NumberBadge ( this . userDataSyncService . conflicts . reduce ( ( result , syncResourceConflict ) => { return result + syncResourceConflict . conflicts . length ; } , 0 ) , ( ) => localize ( 'has conflicts' , "Preferences Sync: Conflicts Detected" ) ) ;
379+ badge = new NumberBadge ( this . userDataSyncService . conflicts . reduce ( ( result , [ , conflicts ] ) => { return result + conflicts . length ; } , 0 ) , ( ) => localize ( 'has conflicts' , "Preferences Sync: Conflicts Detected" ) ) ;
380380 } else if ( this . turningOnSync ) {
381381 badge = new ProgressBadge ( ( ) => localize ( 'turning on syncing' , "Turning on Preferences Sync..." ) ) ;
382382 clazz = 'progress-badge' ;
@@ -611,13 +611,13 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
611611 }
612612
613613 private async handleSyncResourceConflicts ( resource : SyncResource ) : Promise < void > {
614- const syncResourceCoflicts = this . userDataSyncService . conflicts . filter ( ( { syncResource } ) => syncResource === resource ) [ 0 ] ;
614+ const syncResourceCoflicts = this . userDataSyncService . conflicts . filter ( ( [ syncResource ] ) => syncResource === resource ) [ 0 ] ;
615615 if ( syncResourceCoflicts ) {
616616 this . handleConflicts ( syncResourceCoflicts ) ;
617617 }
618618 }
619619
620- private async handleConflicts ( { syncResource, conflicts } : SyncResourceConflicts ) : Promise < void > {
620+ private async handleConflicts ( [ syncResource , conflicts ] : [ SyncResource , IResourcePreview [ ] ] ) : Promise < void > {
621621 for ( const conflict of conflicts ) {
622622 let label : string | undefined = undefined ;
623623 if ( syncResource === SyncResource . Settings ) {
@@ -814,7 +814,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
814814 private registerShowSnippetsConflictsAction ( ) : void {
815815 this . _snippetsConflictsActionsDisposable . clear ( ) ;
816816 const resolveSnippetsConflictsWhenContext = ContextKeyExpr . regex ( CONTEXT_CONFLICTS_SOURCES . keys ( ) [ 0 ] , / .* s n i p p e t s .* / i) ;
817- const conflicts : IResourcePreview [ ] | undefined = this . userDataSyncService . conflicts . filter ( ( { syncResource } ) => syncResource === SyncResource . Snippets ) [ 0 ] ?. conflicts ;
817+ const conflicts : IResourcePreview [ ] | undefined = this . userDataSyncService . conflicts . filter ( ( [ syncResource ] ) => syncResource === SyncResource . Snippets ) [ 0 ] ?. [ 1 ] ;
818818 this . _snippetsConflictsActionsDisposable . add ( CommandsRegistry . registerCommand ( resolveSnippetsConflictsCommand . id , ( ) => this . handleSyncResourceConflicts ( SyncResource . Snippets ) ) ) ;
819819 this . _snippetsConflictsActionsDisposable . add ( MenuRegistry . appendMenuItem ( MenuId . GlobalActivity , {
820820 group : '5_sync' ,
@@ -878,7 +878,7 @@ export class UserDataSyncWorkbenchContribution extends Disposable implements IWo
878878 disposables . add ( quickPick ) ;
879879 const items : Array < IQuickPickItem | IQuickPickSeparator > = [ ] ;
880880 if ( that . userDataSyncService . conflicts . length ) {
881- for ( const { syncResource } of that . userDataSyncService . conflicts ) {
881+ for ( const [ syncResource ] of that . userDataSyncService . conflicts ) {
882882 switch ( syncResource ) {
883883 case SyncResource . Settings :
884884 items . push ( { id : resolveSettingsConflictsCommand . id , label : resolveSettingsConflictsCommand . title } ) ;
@@ -1127,11 +1127,11 @@ class AcceptChangesContribution extends Disposable implements IEditorContributio
11271127 return false ;
11281128 }
11291129
1130- if ( syncResourceConflicts . conflicts . some ( ( { previewResource } ) => isEqual ( previewResource , model . uri ) ) ) {
1130+ if ( syncResourceConflicts [ 1 ] . some ( ( { previewResource } ) => isEqual ( previewResource , model . uri ) ) ) {
11311131 return true ;
11321132 }
11331133
1134- if ( syncResourceConflicts . conflicts . some ( ( { remoteResource } ) => isEqual ( remoteResource , model . uri ) ) ) {
1134+ if ( syncResourceConflicts [ 1 ] . some ( ( { remoteResource } ) => isEqual ( remoteResource , model . uri ) ) ) {
11351135 return this . configurationService . getValue < boolean > ( 'diffEditor.renderSideBySide' ) ;
11361136 }
11371137
@@ -1141,16 +1141,16 @@ class AcceptChangesContribution extends Disposable implements IEditorContributio
11411141 private createAcceptChangesWidgetRenderer ( ) : void {
11421142 if ( ! this . acceptChangesButton ) {
11431143 const resource = this . editor . getModel ( ) ! . uri ;
1144- const syncResourceConflicts = this . getSyncResourceConflicts ( resource ) ! ;
1145- const isRemote = syncResourceConflicts . conflicts . some ( ( { remoteResource } ) => isEqual ( remoteResource , resource ) ) ;
1144+ const [ syncResource , conflicts ] = this . getSyncResourceConflicts ( resource ) ! ;
1145+ const isRemote = conflicts . some ( ( { remoteResource } ) => isEqual ( remoteResource , resource ) ) ;
11461146 const acceptRemoteLabel = localize ( 'accept remote' , "Accept Remote" ) ;
11471147 const acceptLocalLabel = localize ( 'accept local' , "Accept Local" ) ;
11481148 this . acceptChangesButton = this . instantiationService . createInstance ( FloatingClickWidget , this . editor , isRemote ? acceptRemoteLabel : acceptLocalLabel , null ) ;
11491149 this . _register ( this . acceptChangesButton . onClick ( async ( ) => {
11501150 const model = this . editor . getModel ( ) ;
11511151 if ( model ) {
1152- this . telemetryService . publicLog2 < { source : string , action : string } , SyncConflictsClassification > ( 'sync/handleConflicts' , { source : syncResourceConflicts . syncResource , action : isRemote ? 'acceptRemote' : 'acceptLocal' } ) ;
1153- const syncAreaLabel = getSyncAreaLabel ( syncResourceConflicts . syncResource ) ;
1152+ this . telemetryService . publicLog2 < { source : string , action : string } , SyncConflictsClassification > ( 'sync/handleConflicts' , { source : syncResource , action : isRemote ? 'acceptRemote' : 'acceptLocal' } ) ;
1153+ const syncAreaLabel = getSyncAreaLabel ( syncResource ) ;
11541154 const result = await this . dialogService . confirm ( {
11551155 type : 'info' ,
11561156 title : isRemote
@@ -1163,11 +1163,11 @@ class AcceptChangesContribution extends Disposable implements IEditorContributio
11631163 } ) ;
11641164 if ( result . confirmed ) {
11651165 try {
1166- await this . userDataSyncService . acceptPreviewContent ( syncResourceConflicts . syncResource , model . uri , model . getValue ( ) ) ;
1166+ await this . userDataSyncService . acceptPreviewContent ( syncResource , model . uri , model . getValue ( ) ) ;
11671167 } catch ( e ) {
11681168 if ( e instanceof UserDataSyncError && e . code === UserDataSyncErrorCode . LocalPreconditionFailed ) {
1169- const syncResourceCoflicts = this . userDataSyncService . conflicts . filter ( ( { syncResource } ) => syncResource === syncResourceConflicts . syncResource ) [ 0 ] ;
1170- if ( syncResourceCoflicts && syncResourceCoflicts . conflicts . some ( conflict => isEqual ( conflict . previewResource , model . uri ) || isEqual ( conflict . remoteResource , model . uri ) ) ) {
1169+ const syncResourceCoflicts = this . userDataSyncService . conflicts . filter ( syncResourceCoflicts => syncResourceCoflicts [ 0 ] === syncResource ) [ 0 ] ;
1170+ if ( syncResourceCoflicts && conflicts . some ( conflict => isEqual ( conflict . previewResource , model . uri ) || isEqual ( conflict . remoteResource , model . uri ) ) ) {
11711171 this . notificationService . warn ( localize ( 'update conflicts' , "Could not resolve conflicts as there is new local version available. Please try again." ) ) ;
11721172 }
11731173 } else {
@@ -1182,8 +1182,8 @@ class AcceptChangesContribution extends Disposable implements IEditorContributio
11821182 }
11831183 }
11841184
1185- private getSyncResourceConflicts ( resource : URI ) : SyncResourceConflicts | undefined {
1186- return this . userDataSyncService . conflicts . filter ( ( { conflicts } ) => conflicts . some ( ( { previewResource, remoteResource } ) => isEqual ( previewResource , resource ) || isEqual ( remoteResource , resource ) ) ) [ 0 ] ;
1185+ private getSyncResourceConflicts ( resource : URI ) : [ SyncResource , IResourcePreview [ ] ] | undefined {
1186+ return this . userDataSyncService . conflicts . filter ( ( [ , conflicts ] ) => conflicts . some ( ( { previewResource, remoteResource } ) => isEqual ( previewResource , resource ) || isEqual ( remoteResource , resource ) ) ) [ 0 ] ;
11871187 }
11881188
11891189 private disposeAcceptChangesWidgetRenderer ( ) : void {
0 commit comments