@@ -378,7 +378,7 @@ exports.Rewriter = class Rewriter
378378 # and the implicit object didn't start the line or the next line doesn’t look like
379379 # the continuation of an object.
380380 else if inImplicitObject () and tag is ' TERMINATOR' and prevTag isnt ' ,' and
381- not (startsLine and @ looksObjectish (i + 1 ))
381+ not (startsLine and ( @ looksObjectish (i + 1 ) or @ isLeadingLogical (i) ))
382382 endImplicitObject ()
383383 else if inImplicitControl () and tokens[stackTop ()[1 ]][0 ] is ' CLASS' and tag is ' TERMINATOR'
384384 stack .pop ()
@@ -645,8 +645,7 @@ exports.Rewriter = class Rewriter
645645 condition = (token , i ) ->
646646 [tag ] = token
647647 [prevTag ] = @tokens [i - 1 ]
648- [nextTag ] = @tokens [i + 1 ] unless i is @tokens .length - 1
649- tag is ' TERMINATOR' and nextTag not in LEADING_LOGICAL or (tag is ' INDENT' and prevTag not in SINGLE_LINERS)
648+ tag is ' TERMINATOR' and not @ isLeadingLogical (i) or (tag is ' INDENT' and prevTag not in SINGLE_LINERS)
650649
651650 action = (token , i ) ->
652651 if token[0 ] isnt ' INDENT' or (token .generated and not token .fromThen )
@@ -671,6 +670,11 @@ exports.Rewriter = class Rewriter
671670 token[1 ].generated = yes if token .generated
672671 1
673672
673+ # Returns `yes` if standing in front of what will become a LEADING_AND or
674+ # LEADING_OR, ie TERMINATOR followed by && or ||
675+ isLeadingLogical : (i ) ->
676+ @ tag (i) is ' TERMINATOR' and @ tag (i + 1 ) in LEADING_LOGICAL
677+
674678 # Convert TERMINATOR followed by && or || into a single LEADING_AND or
675679 # LEADING_OR token to disambiguate grammar.
676680 tagLeadingLogical : ->
0 commit comments