double brackets does not leave brackets behind, to align with the most common scenarios

This commit is contained in:
Luke Page
2013-02-02 23:57:31 +00:00
parent 6cd6fb2585
commit c2880a9baa
2 changed files with 9 additions and 5 deletions

View File

@@ -4,7 +4,8 @@ tree.Expression = function (value) { this.value = value; };
tree.Expression.prototype = {
eval: function (env) {
var returnValue,
inParenthesis = this.parens && !this.parensInOp;
inParenthesis = this.parens && !this.parensInOp,
doubleParen = false;
if (inParenthesis) {
env.inParenthesis();
}
@@ -13,6 +14,9 @@ tree.Expression.prototype = {
return e.eval(env);
}));
} else if (this.value.length === 1) {
if (this.value[0].parens && !this.value[0].parensInOp) {
doubleParen = true;
}
returnValue = this.value[0].eval(env);
} else {
returnValue = this;
@@ -20,7 +24,7 @@ tree.Expression.prototype = {
if (inParenthesis) {
env.outOfParenthesis();
}
if (this.parens && this.parensInOp && !(env.isMathsOn())) {
if (this.parens && this.parensInOp && !(env.isMathsOn()) && !doubleParen) {
returnValue = new(tree.Paren)(returnValue);
}
return returnValue;

View File

@@ -7,16 +7,16 @@
.more-parens {
padding: 8 4 4 4px;
width-all: 96;
width-first: (16) * 6;
width-first: 16 * 6;
width-keep: (4 * 4) * 6;
height-keep: (7 * 7) + (8 * 8);
height-all: 113;
height-parts: (49) + (64);
height-parts: 49 + 64;
margin-keep: (4 * (5 + 5) / 2) - (4 * 2);
margin-parts: 20 - 8;
margin-all: 12;
border-radius-keep: 4px * (1 + 1) / 4 + 3px;
border-radius-parts: (8px) / (7px);
border-radius-parts: 8px / 7px;
border-radius-all: 5px;
}
.negative {