@@ -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 ()
@@ -650,8 +650,7 @@ exports.Rewriter = class Rewriter
650650 condition = (token , i ) ->
651651 [tag ] = token
652652 [prevTag ] = @tokens [i - 1 ]
653- [nextTag ] = @tokens [i + 1 ] unless i is @tokens .length - 1
654- tag is ' TERMINATOR' and nextTag not in LEADING_LOGICAL or (tag is ' INDENT' and prevTag not in SINGLE_LINERS)
653+ tag is ' TERMINATOR' and not @ isLeadingLogical (i) or (tag is ' INDENT' and prevTag not in SINGLE_LINERS)
655654
656655 action = (token , i ) ->
657656 if token[0 ] isnt ' INDENT' or (token .generated and not token .fromThen )
@@ -663,6 +662,11 @@ exports.Rewriter = class Rewriter
663662 @ detectEnd i + 1 , condition, action
664663 return 1
665664
665+ # Returns `yes` if standing in front of what will become a LEADING_AND or
666+ # LEADING_OR, ie TERMINATOR followed by && or ||
667+ isLeadingLogical : (i ) ->
668+ @ tag (i) is ' TERMINATOR' and @ tag (i + 1 ) in LEADING_LOGICAL
669+
666670 # Convert TERMINATOR followed by && or || into a single LEADING_AND or
667671 # LEADING_OR token to disambiguate grammar.
668672 tagLeadingLogical : ->
0 commit comments