Skip to content

Commit b6840cf

Browse files
committed
allow leading logical operators
1 parent 7cf739e commit b6840cf

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

lib/coffeescript/lexer.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lexer.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,7 @@ POSSIBLY_DIVISION = /// ^ /=?\s ///
12931293
# Other regexes.
12941294
HERECOMMENT_ILLEGAL = /\*\//
12951295
1296-
LINE_CONTINUER = /// ^ \s* (?: , | \??\.(?![.\d]) | \??:: ) ///
1296+
LINE_CONTINUER = /// ^ \s* (?: , | \??\.(?![.\d]) | \??:: | and#{' '} | or#{' '} | && | \|\| ) ///
12971297
12981298
STRING_INVALID_ESCAPE = ///
12991299
( (?:^|[^\\]) (?:\\\\)* ) # Make sure the escape isn’t escaped.

test/formatting.coffee

+29
Original file line numberDiff line numberDiff line change
@@ -454,3 +454,32 @@ test "#3736: chaining after do IIFE", ->
454454
eq 4,
455455
do b
456456
.c
457+
458+
test "logical and/or should continue lines", ->
459+
ok not (
460+
yes
461+
and no
462+
)
463+
464+
ok not (
465+
1
466+
and 0
467+
)
468+
469+
ok 'abc'
470+
&& 123
471+
472+
ok 'abc'
473+
&& 123
474+
475+
ok 'abc'
476+
or 123
477+
478+
ok 'abc'
479+
or 123
480+
481+
ok 'abc'
482+
|| 123
483+
484+
ok 'abc'
485+
|| 123

0 commit comments

Comments
 (0)