Skip to content

Commit a850f06

Browse files
committed
Fix for block formatting
- work with blocks that come after a keyword group and newline
1 parent 0caae7d commit a850f06

File tree

5 files changed

+14
-1
lines changed

5 files changed

+14
-1
lines changed

models/cfscript/Blocks.cfc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ component {
1414
indent,
1515
columnOffset
1616
) {
17-
var element = cftokens.next(false);
17+
var element = cftokens.next(false, true);
1818

1919
var blockFormatted = cfformat.cfscript
2020
.print(
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
if () {
2+
}
3+
switch () {
4+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{}]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//
2+
if ()
3+
{}
4+
switch ()
5+
{}

tests/specs/blockSpec.cfc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ component extends=tests.FormatBaseSpec {
22

33
function run() {
44
describe('The block printer', function() {
5+
it('handles newlines before the block', function() {
6+
runTests(loadData('blockAfterNewline'));
7+
});
58
it('ensures a newline after the block', function() {
69
runTests(loadData('blocks'));
710
});

0 commit comments

Comments
 (0)