File tree Expand file tree Collapse file tree
src/vs/platform/contextkey Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -884,6 +884,10 @@ export class ContextKeyAndExpr implements IContextKeyExpression {
884884 }
885885 }
886886
887+ if ( expr . length === 1 ) {
888+ return expr [ 0 ] ;
889+ }
890+
887891 return new ContextKeyAndExpr ( expr ) ;
888892 }
889893
Original file line number Diff line number Diff line change @@ -165,4 +165,25 @@ suite('ContextKeyExpr', () => {
165165 assert . equal ( ainb . evaluate ( createContext ( { 'a' : 'x' , 'b' : { 'x' : true } } ) ) , true ) ;
166166 assert . equal ( ainb . evaluate ( createContext ( { 'a' : 'prototype' , 'b' : { } } ) ) , false ) ;
167167 } ) ;
168+
169+ test ( 'issue #106524: distributing AND should normalize' , ( ) => {
170+ const actual = ContextKeyExpr . and (
171+ ContextKeyExpr . or (
172+ ContextKeyExpr . has ( 'a' ) ,
173+ ContextKeyExpr . has ( 'b' )
174+ ) ,
175+ ContextKeyExpr . has ( 'c' )
176+ ) ;
177+ const expected = ContextKeyExpr . or (
178+ ContextKeyExpr . and (
179+ ContextKeyExpr . has ( 'a' ) ,
180+ ContextKeyExpr . has ( 'c' )
181+ ) ,
182+ ContextKeyExpr . and (
183+ ContextKeyExpr . has ( 'b' ) ,
184+ ContextKeyExpr . has ( 'c' )
185+ )
186+ ) ;
187+ assert . equal ( actual ! . equals ( expected ! ) , true ) ;
188+ } ) ;
168189} ) ;
You can’t perform that action at this time.
0 commit comments