You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -714,29 +705,56 @@ export class ContextKeyAndExpr implements IContextKeyExpression {
714
705
715
706
if(e.type===ContextKeyExprType.False){
716
707
// anything && false ==> false
717
-
return[ContextKeyFalseExpr.INSTANCE];
708
+
returnContextKeyFalseExpr.INSTANCE;
718
709
}
719
710
720
711
if(e.type===ContextKeyExprType.And){
721
712
expr.push(...e.expr);
722
713
continue;
723
714
}
724
715
725
-
if(e.type===ContextKeyExprType.Or){
726
-
// Not allowed, because we don't have parens!
727
-
thrownewError(`It is not allowed to have an or expression here due to lack of parens! For example "a && (b||c)" is not supported, use "(a&&b) || (a&&c)" instead.`);
728
-
}
729
-
730
716
expr.push(e);
731
717
}
732
718
733
719
if(expr.length===0&&hasTrue){
734
-
return[ContextKeyTrueExpr.INSTANCE];
720
+
returnContextKeyTrueExpr.INSTANCE;
721
+
}
722
+
723
+
if(expr.length===0){
724
+
returnundefined;
725
+
}
726
+
727
+
if(expr.length===1){
728
+
returnexpr[0];
735
729
}
736
730
737
731
expr.sort(cmp);
738
732
739
-
returnexpr;
733
+
// We must distribute any OR expression because we don't support parens
734
+
// OR extensions will be at the end (due to sorting rules)
735
+
while(expr.length>1){
736
+
constlastElement=expr[expr.length-1];
737
+
if(lastElement.type!==ContextKeyExprType.Or){
738
+
break;
739
+
}
740
+
// pop the last element
741
+
expr.pop();
742
+
743
+
// pop the second to last element
744
+
constsecondToLastElement=expr.pop()!;
745
+
746
+
// distribute `lastElement` over `secondToLastElement`
0 commit comments