Spacing multiple operators.

This commit is contained in:
Timothy Jones
2010-10-24 00:01:26 +13:00
parent 2bc2c4717e
commit 9448a477d2
3 changed files with 6 additions and 2 deletions

View File

@@ -1291,7 +1291,7 @@
};
Op.prototype.compileUnary = function(o) {
var _ref2, parts, space;
space = (_ref2 = this.operator, __indexOf.call(this.PREFIX_OPERATORS, _ref2) >= 0) ? ' ' : '';
space = (_ref2 = this.operator, __indexOf.call(this.PREFIX_OPERATORS, _ref2) >= 0) || this.first instanceof Op ? ' ' : '';
parts = [this.operator, space, this.first.compile(o, LVL_OP)];
return (this.flip ? parts.reverse() : parts).join('');
};

View File

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

View File

@@ -165,3 +165,7 @@ ok a is 579
a = "1#{2}3" +
"456"
ok a is '123456'
# Multiple operators should space themselves.
ok + +1 is - -1