55
66import * as objects from 'vs/base/common/objects' ;
77import { parse } from 'vs/base/common/json' ;
8- import { keys } from 'vs/base/common/map' ;
98import { IUserFriendlyKeybinding } from 'vs/platform/keybinding/common/keybinding' ;
109import { firstIndex as findFirstIndex , equals } from 'vs/base/common/arrays' ;
1110import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey' ;
@@ -57,8 +56,8 @@ export async function merge(localContent: string, remoteContent: string, baseCon
5756 const remoteByCommand = byCommand ( remote ) ;
5857 const baseByCommand = base ? byCommand ( base ) : null ;
5958 const localToRemoteByCommand = compareByCommand ( localByCommand , remoteByCommand , normalizedKeys ) ;
60- const baseToLocalByCommand = baseByCommand ? compareByCommand ( baseByCommand , localByCommand , normalizedKeys ) : { added : keys ( localByCommand ) . reduce ( ( r , k ) => { r . add ( k ) ; return r ; } , new Set < string > ( ) ) , removed : new Set < string > ( ) , updated : new Set < string > ( ) } ;
61- const baseToRemoteByCommand = baseByCommand ? compareByCommand ( baseByCommand , remoteByCommand , normalizedKeys ) : { added : keys ( remoteByCommand ) . reduce ( ( r , k ) => { r . add ( k ) ; return r ; } , new Set < string > ( ) ) , removed : new Set < string > ( ) , updated : new Set < string > ( ) } ;
59+ const baseToLocalByCommand = baseByCommand ? compareByCommand ( baseByCommand , localByCommand , normalizedKeys ) : { added : [ ... localByCommand . keys ( ) ] . reduce ( ( r , k ) => { r . add ( k ) ; return r ; } , new Set < string > ( ) ) , removed : new Set < string > ( ) , updated : new Set < string > ( ) } ;
60+ const baseToRemoteByCommand = baseByCommand ? compareByCommand ( baseByCommand , remoteByCommand , normalizedKeys ) : { added : [ ... remoteByCommand . keys ( ) ] . reduce ( ( r , k ) => { r . add ( k ) ; return r ; } , new Set < string > ( ) ) , removed : new Set < string > ( ) , updated : new Set < string > ( ) } ;
6261
6362 const commandsMergeResult = computeMergeResult ( localToRemoteByCommand , baseToLocalByCommand , baseToRemoteByCommand ) ;
6463 let mergeContent = localContent ;
@@ -204,13 +203,13 @@ function computeMergeResultByKeybinding(local: IUserFriendlyKeybinding[], remote
204203 return { hasLocalForwarded : false , hasRemoteForwarded : false , added : empty , removed : empty , updated : empty , conflicts : empty } ;
205204 }
206205
207- const baseToLocalByKeybinding = baseByKeybinding ? compareByKeybinding ( baseByKeybinding , localByKeybinding ) : { added : keys ( localByKeybinding ) . reduce ( ( r , k ) => { r . add ( k ) ; return r ; } , new Set < string > ( ) ) , removed : new Set < string > ( ) , updated : new Set < string > ( ) } ;
206+ const baseToLocalByKeybinding = baseByKeybinding ? compareByKeybinding ( baseByKeybinding , localByKeybinding ) : { added : [ ... localByKeybinding . keys ( ) ] . reduce ( ( r , k ) => { r . add ( k ) ; return r ; } , new Set < string > ( ) ) , removed : new Set < string > ( ) , updated : new Set < string > ( ) } ;
208207 if ( baseToLocalByKeybinding . added . size === 0 && baseToLocalByKeybinding . removed . size === 0 && baseToLocalByKeybinding . updated . size === 0 ) {
209208 // Remote has moved forward and local has not.
210209 return { hasLocalForwarded : false , hasRemoteForwarded : true , added : empty , removed : empty , updated : empty , conflicts : empty } ;
211210 }
212211
213- const baseToRemoteByKeybinding = baseByKeybinding ? compareByKeybinding ( baseByKeybinding , remoteByKeybinding ) : { added : keys ( remoteByKeybinding ) . reduce ( ( r , k ) => { r . add ( k ) ; return r ; } , new Set < string > ( ) ) , removed : new Set < string > ( ) , updated : new Set < string > ( ) } ;
212+ const baseToRemoteByKeybinding = baseByKeybinding ? compareByKeybinding ( baseByKeybinding , remoteByKeybinding ) : { added : [ ... remoteByKeybinding . keys ( ) ] . reduce ( ( r , k ) => { r . add ( k ) ; return r ; } , new Set < string > ( ) ) , removed : new Set < string > ( ) , updated : new Set < string > ( ) } ;
214213 if ( baseToRemoteByKeybinding . added . size === 0 && baseToRemoteByKeybinding . removed . size === 0 && baseToRemoteByKeybinding . updated . size === 0 ) {
215214 return { hasLocalForwarded : true , hasRemoteForwarded : false , added : empty , removed : empty , updated : empty , conflicts : empty } ;
216215 }
@@ -250,8 +249,8 @@ function byCommand(keybindings: IUserFriendlyKeybinding[]): Map<string, IUserFri
250249
251250
252251function compareByKeybinding ( from : Map < string , IUserFriendlyKeybinding [ ] > , to : Map < string , IUserFriendlyKeybinding [ ] > ) : ICompareResult {
253- const fromKeys = keys ( from ) ;
254- const toKeys = keys ( to ) ;
252+ const fromKeys = [ ... from . keys ( ) ] ;
253+ const toKeys = [ ... to . keys ( ) ] ;
255254 const added = toKeys . filter ( key => fromKeys . indexOf ( key ) === - 1 ) . reduce ( ( r , key ) => { r . add ( key ) ; return r ; } , new Set < string > ( ) ) ;
256255 const removed = fromKeys . filter ( key => toKeys . indexOf ( key ) === - 1 ) . reduce ( ( r , key ) => { r . add ( key ) ; return r ; } , new Set < string > ( ) ) ;
257256 const updated : Set < string > = new Set < string > ( ) ;
@@ -271,8 +270,8 @@ function compareByKeybinding(from: Map<string, IUserFriendlyKeybinding[]>, to: M
271270}
272271
273272function compareByCommand ( from : Map < string , IUserFriendlyKeybinding [ ] > , to : Map < string , IUserFriendlyKeybinding [ ] > , normalizedKeys : IStringDictionary < string > ) : ICompareResult {
274- const fromKeys = keys ( from ) ;
275- const toKeys = keys ( to ) ;
273+ const fromKeys = [ ... from . keys ( ) ] ;
274+ const toKeys = [ ... to . keys ( ) ] ;
276275 const added = toKeys . filter ( key => fromKeys . indexOf ( key ) === - 1 ) . reduce ( ( r , key ) => { r . add ( key ) ; return r ; } , new Set < string > ( ) ) ;
277276 const removed = fromKeys . filter ( key => toKeys . indexOf ( key ) === - 1 ) . reduce ( ( r , key ) => { r . add ( key ) ; return r ; } , new Set < string > ( ) ) ;
278277 const updated : Set < string > = new Set < string > ( ) ;
0 commit comments