Skip to content

Commit eb70092

Browse files
zdenkoGeoffreyBooth
authored andcommitted
fix #4898 (#4899)
1 parent 571e9df commit eb70092

File tree

3 files changed

+57
-3
lines changed

3 files changed

+57
-3
lines changed

lib/coffeescript/lexer.js

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lexer.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ exports.Lexer = class Lexer
478478

479479
if size > @indent
480480
if noNewlines
481-
@indebt = size - @indent
481+
@indebt = size - @indent unless backslash
482482
@suppressNewlines()
483483
return indent.length
484484
unless @tokens.length

test/control_flow.coffee

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,3 +1287,56 @@ test "#4871: `else if` no longer output together ", ->
12871287
2;
12881288
}
12891289
'''
1290+
1291+
test "#4898: Lexer: backslash line continuation is inconsistent", ->
1292+
if ( \
1293+
false \
1294+
or \
1295+
true \
1296+
)
1297+
a = 42
1298+
1299+
eq a, 42
1300+
1301+
if ( \
1302+
false \
1303+
or \
1304+
true \
1305+
)
1306+
b = 42
1307+
1308+
eq b, 42
1309+
1310+
if ( \
1311+
false \
1312+
or \
1313+
true \
1314+
)
1315+
c = 42
1316+
1317+
eq c, 42
1318+
1319+
if \
1320+
false \
1321+
or \
1322+
true
1323+
d = 42
1324+
1325+
eq d, 42
1326+
1327+
if \
1328+
false or \
1329+
true
1330+
e = 42
1331+
1332+
eq e, 42
1333+
1334+
if \
1335+
false or \
1336+
true \
1337+
then \
1338+
f = 42 \
1339+
else
1340+
f = 24
1341+
1342+
eq f, 42

0 commit comments

Comments
 (0)