mirror of
https://github.com/jashkenas/coffeescript.git
synced 2026-01-14 17:27:59 -05:00
Spacing multiple operators.
This commit is contained in:
@@ -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('');
|
||||
};
|
||||
|
||||
@@ -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 ''
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user