Skip to content

Commit fb3a10a

Browse files
authored
fixed maxLineLength wrapping of OpBool chains, fixes #572 (#574)
1 parent feeb6a9 commit fb3a10a

File tree

6 files changed

+211
-35
lines changed

6 files changed

+211
-35
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
- Added detection for and skipping files with merge conflicts, fixes [#558](https://github.com/HaxeCheckstyle/haxe-formatter/issues/558) ([#559](https://github.com/HaxeCheckstyle/haxe-formatter/issues/559))
77
- Added case pattern wrapping with `wrapping.casePattern`, fixes [#359](https://github.com/HaxeCheckstyle/haxe-formatter/issues/359) ([#566](https://github.com/HaxeCheckstyle/haxe-formatter/issues/566))
88
- Added support for `var @:meta name` ([#568](https://github.com/HaxeCheckstyle/haxe-formatter/issues/568))
9-
- Added new wrapping rule condition type `exceedsMaxLineLength`, fixes [#572](https://github.com/HaxeCheckstyle/haxe-formatter/issues/572) ([#573](https://github.com/HaxeCheckstyle/haxe-formatter/issues/573))
9+
- Added new wrapping rule condition type `exceedsMaxLineLength`, fixes [#572](https://github.com/HaxeCheckstyle/haxe-formatter/issues/572) ([#573](https://github.com/HaxeCheckstyle/haxe-formatter/issues/573) + [#574](https://github.com/HaxeCheckstyle/haxe-formatter/issues/574))
1010
- Fixed indentation of wrapped callbacks, fixes [#470](https://github.com/HaxeCheckstyle/haxe-formatter/issues/470), [#476](https://github.com/HaxeCheckstyle/haxe-formatter/issues/476), [#540](https://github.com/HaxeCheckstyle/haxe-formatter/issues/540), [#546](https://github.com/HaxeCheckstyle/haxe-formatter/issues/546) ([#548](https://github.com/HaxeCheckstyle/haxe-formatter/issues/548))
1111
- Fixed indentation of array literals in calls, fixes [#376](https://github.com/HaxeCheckstyle/haxe-formatter/issues/367) ([#548](https://github.com/HaxeCheckstyle/haxe-formatter/issues/548))
1212
- Fixed indentation of array literals in assignments, fixes [#512](https://github.com/HaxeCheckstyle/haxe-formatter/issues/512) ([#548](https://github.com/HaxeCheckstyle/haxe-formatter/issues/548))

resources/default-hxformat.json

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@
287287
{
288288
"conditions": [
289289
{
290-
"cond": "exceedsMaxLineLength"
290+
"cond": "exceedsMaxLineLength",
291+
"value": 1
291292
}
292293
],
293294
"type": "fillLine",
@@ -303,6 +304,10 @@
303304
{
304305
"cond": "itemCount <= n",
305306
"value": 3
307+
},
308+
{
309+
"cond": "exceedsMaxLineLength",
310+
"value": 0
306311
}
307312
],
308313
"type": "noWrap"
@@ -337,7 +342,8 @@
337342
{
338343
"conditions": [
339344
{
340-
"cond": "exceedsMaxLineLength"
345+
"cond": "exceedsMaxLineLength",
346+
"value": 1
341347
}
342348
],
343349
"type": "fillLine"
@@ -396,7 +402,8 @@
396402
{
397403
"conditions": [
398404
{
399-
"cond": "exceedsMaxLineLength"
405+
"cond": "exceedsMaxLineLength",
406+
"value": 1
400407
}
401408
],
402409
"type": "onePerLine"
@@ -445,7 +452,8 @@
445452
{
446453
"conditions": [
447454
{
448-
"cond": "exceedsMaxLineLength"
455+
"cond": "exceedsMaxLineLength",
456+
"value": 1
449457
}
450458
],
451459
"type": "fillLine"
@@ -469,7 +477,8 @@
469477
{
470478
"conditions": [
471479
{
472-
"cond": "exceedsMaxLineLength"
480+
"cond": "exceedsMaxLineLength",
481+
"value": 1
473482
}
474483
],
475484
"location": "beforeLast",
@@ -508,7 +517,8 @@
508517
{
509518
"conditions": [
510519
{
511-
"cond": "exceedsMaxLineLength"
520+
"cond": "exceedsMaxLineLength",
521+
"value": 1
512522
}
513523
],
514524
"type": "fillLine",
@@ -541,7 +551,8 @@
541551
{
542552
"conditions": [
543553
{
544-
"cond": "exceedsMaxLineLength"
554+
"cond": "exceedsMaxLineLength",
555+
"value": 1
545556
}
546557
],
547558
"type": "fillLine"
@@ -565,6 +576,10 @@
565576
{
566577
"cond": "itemCount <= n",
567578
"value": 3
579+
},
580+
{
581+
"cond": "exceedsMaxLineLength",
582+
"value": 0
568583
}
569584
],
570585
"type": "noWrap"
@@ -574,6 +589,10 @@
574589
{
575590
"cond": "totalItemLength <= n",
576591
"value": 80
592+
},
593+
{
594+
"cond": "exceedsMaxLineLength",
595+
"value": 0
577596
}
578597
],
579598
"type": "noWrap"
@@ -603,7 +622,8 @@
603622
{
604623
"conditions": [
605624
{
606-
"cond": "exceedsMaxLineLength"
625+
"cond": "exceedsMaxLineLength",
626+
"value": 1
607627
}
608628
],
609629
"type": "onePerLineAfterFirst"
@@ -634,7 +654,8 @@
634654
{
635655
"conditions": [
636656
{
637-
"cond": "exceedsMaxLineLength"
657+
"cond": "exceedsMaxLineLength",
658+
"value": 1
638659
}
639660
],
640661
"type": "onePerLineAfterFirst"
@@ -649,6 +670,10 @@
649670
{
650671
"cond": "itemCount <= n",
651672
"value": 3
673+
},
674+
{
675+
"cond": "exceedsMaxLineLength",
676+
"value": 0
652677
}
653678
],
654679
"type": "noWrap"
@@ -683,7 +708,8 @@
683708
{
684709
"conditions": [
685710
{
686-
"cond": "exceedsMaxLineLength"
711+
"cond": "exceedsMaxLineLength",
712+
"value": 1
687713
}
688714
],
689715
"type": "onePerLine"
@@ -722,6 +748,10 @@
722748
{
723749
"cond": "itemCount <= n",
724750
"value": 3
751+
},
752+
{
753+
"cond": "exceedsMaxLineLength",
754+
"value": 0
725755
}
726756
],
727757
"type": "noWrap"
@@ -731,6 +761,10 @@
731761
{
732762
"cond": "totalItemLength <= n",
733763
"value": 120
764+
},
765+
{
766+
"cond": "exceedsMaxLineLength",
767+
"value": 0
734768
}
735769
],
736770
"type": "noWrap"
@@ -748,7 +782,8 @@
748782
{
749783
"conditions": [
750784
{
751-
"cond": "exceedsMaxLineLength"
785+
"cond": "exceedsMaxLineLength",
786+
"value": 1
752787
}
753788
],
754789
"location": "beforeLast",
@@ -788,6 +823,10 @@
788823
{
789824
"cond": "itemCount <= n",
790825
"value": 3
826+
},
827+
{
828+
"cond": "exceedsMaxLineLength",
829+
"value": 0
791830
}
792831
],
793832
"type": "noWrap"
@@ -797,6 +836,10 @@
797836
{
798837
"cond": "totalItemLength <= n",
799838
"value": 120
839+
},
840+
{
841+
"cond": "exceedsMaxLineLength",
842+
"value": 0
800843
}
801844
],
802845
"type": "noWrap"
@@ -814,9 +857,11 @@
814857
{
815858
"conditions": [
816859
{
817-
"cond": "exceedsMaxLineLength"
860+
"cond": "exceedsMaxLineLength",
861+
"value": 1
818862
}
819863
],
864+
"location": "beforeLast",
820865
"type": "fillLine"
821866
}
822867
]

resources/hxformat-schema.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,33 +576,43 @@
576576
"formatter.config.WrapConditionType": {
577577
"anyOf": [
578578
{
579+
"description": "condition matches if item count is larger than or equal n characters",
579580
"const": "itemCount >= n"
580581
},
581582
{
583+
"description": "condition matches if item count is less than or equal n characters",
582584
"const": "itemCount <= n"
583585
},
584586
{
587+
"description": "condition matches if max item length is larger than or equal n characters",
585588
"const": "anyItemLength >= n"
586589
},
587590
{
591+
"description": "condition matches if max item length is less than or equal n characters",
588592
"const": "anyItemLength <= n"
589593
},
590594
{
595+
"description": "condition matches if total length of all wrapable items is larger than or equal n characters",
591596
"const": "totalItemLength >= n"
592597
},
593598
{
599+
"description": "condition matches if total length of all wrapable items is less than or equal n characters",
594600
"const": "totalItemLength <= n"
595601
},
596602
{
603+
"description": "condition matches lines larger than or equal n characters",
597604
"const": "lineLength >= n"
598605
},
599606
{
607+
"description": "condition matches lines less than or equal n characters",
600608
"const": "lineLength <= n"
601609
},
602610
{
611+
"description": "condition value = 1 matches if line contains a multiline token (string literal, block comment) value = 0 matches if no multiline token is present",
603612
"const": "hasMultilineItems"
604613
},
605614
{
615+
"description": "condition value = 1 matches if unwrapped line exceeds maxLineLength value = 0 matches unwrapped lines not exceeding maxLineLength",
606616
"const": "exceedsMaxLineLength"
607617
}
608618
]
@@ -964,24 +974,31 @@
964974
"formatter.config.WrappingType": {
965975
"anyOf": [
966976
{
977+
"description": "every item in a separate line, including first item",
967978
"const": "onePerLine"
968979
},
969980
{
981+
"description": "every item in a separate line, except first item",
970982
"const": "onePerLineAfterFirst"
971983
},
972984
{
985+
"description": "put an equal amount of items per line - not yet implemented",
973986
"const": "equalNumber"
974987
},
975988
{
989+
"description": "fill each line until maxLineLength - does not start with a newline",
976990
"const": "fillLine"
977991
},
978992
{
993+
"description": "fill each line until maxLineLength, starts with a newline before first item",
979994
"const": "fillLineWithLeadingBreak"
980995
},
981996
{
997+
"description": "do not wrap items",
982998
"const": "noWrap"
983999
},
9841000
{
1001+
"description": "use wrapping information from source",
9851002
"const": "keep"
9861003
}
9871004
]

0 commit comments

Comments
 (0)