Spacing only + and - and only in a row.

This commit is contained in:
Timothy Jones
2010-10-24 00:13:48 +13:00
parent 9448a477d2
commit e6fb3bcffb
2 changed files with 4 additions and 3 deletions

View File

@@ -1290,8 +1290,8 @@
return new Existence(fst).compile(o) + (" ? " + ref + " : " + (this.second.compile(o, LVL_LIST)));
};
Op.prototype.compileUnary = function(o) {
var _ref2, parts, space;
space = (_ref2 = this.operator, __indexOf.call(this.PREFIX_OPERATORS, _ref2) >= 0) || this.first instanceof Op ? ' ' : '';
var _ref2, _ref3, parts, space;
space = (_ref2 = this.operator, __indexOf.call(this.PREFIX_OPERATORS, _ref2) >= 0) || this.first instanceof Op && this.first.operator === this.operator && ((_ref3 = this.operator) === '+' || _ref3 === '-') ? ' ' : '';
parts = [this.operator, space, this.first.compile(o, LVL_OP)];
return (this.flip ? parts.reverse() : parts).join('');
};

View File

@@ -1108,7 +1108,8 @@ exports.Op = class Op extends Base
# Compile a unary **Op**.
compileUnary: (o) ->
space = if @operator in @PREFIX_OPERATORS or @first instanceof Op then ' ' else ''
space = if @operator in @PREFIX_OPERATORS or @first instanceof Op and
@first.operator is @operator and @operator in ['+', '-'] then ' ' else ''
parts = [@operator, space, @first.compile(o, LVL_OP)]
(if @flip then parts.reverse() else parts).join ''