@@ -466,5 +466,123 @@ public void SubFooTokenIsNotInterpretedAsProcedureStart()
466
466
var actual = indenter . Indent ( code , string . Empty ) ;
467
467
Assert . IsTrue ( expected . SequenceEqual ( actual ) ) ;
468
468
}
469
+
470
+ //https://github.com/rubberduck-vba/Rubberduck/issues/2133
471
+ [ TestMethod ]
472
+ [ TestCategory ( "Indenter" ) ]
473
+ public void MultiLineDimWithCommasDontAlignDimWorks ( )
474
+ {
475
+ var code = new [ ]
476
+ {
477
+ "Public Sub FooBar()" ,
478
+ "Dim foo As Boolean, bar As String _" ,
479
+ ", baz As String _" ,
480
+ ", somethingElse As String" ,
481
+ "Dim x As Integer" ,
482
+ "If Not foo Then" ,
483
+ "x = 1" ,
484
+ "End If" ,
485
+ "End Sub"
486
+ } ;
487
+
488
+ var expected = new [ ]
489
+ {
490
+ "Public Sub FooBar()" ,
491
+ " Dim foo As Boolean, bar As String _" ,
492
+ " , baz As String _" ,
493
+ " , somethingElse As String" ,
494
+ " Dim x As Integer" ,
495
+ " If Not foo Then" ,
496
+ " x = 1" ,
497
+ " End If" ,
498
+ "End Sub"
499
+ } ;
500
+
501
+ var indenter = new Indenter ( null , ( ) => IndenterSettingsTests . GetMockIndenterSettings ( ) ) ;
502
+ var actual = indenter . Indent ( code , string . Empty ) ;
503
+ Assert . IsTrue ( expected . SequenceEqual ( actual ) ) ;
504
+ }
505
+
506
+ //https://github.com/rubberduck-vba/Rubberduck/issues/2133
507
+ [ TestMethod ]
508
+ [ TestCategory ( "Indenter" ) ]
509
+ public void MultiLineDimWithCommasAlignDimsWorks ( )
510
+ {
511
+ var code = new [ ]
512
+ {
513
+ "Public Sub FooBar()" ,
514
+ "Dim foo As Boolean, bar As String _" ,
515
+ ", baz As String _" ,
516
+ ", somethingElse As String" ,
517
+ "Dim x As Integer" ,
518
+ "If Not foo Then" ,
519
+ "x = 1" ,
520
+ "End If" ,
521
+ "End Sub"
522
+ } ;
523
+
524
+ var expected = new [ ]
525
+ {
526
+ "Public Sub FooBar()" ,
527
+ " Dim foo As Boolean, bar As String _" ,
528
+ " , baz As String _" ,
529
+ " , somethingElse As String" ,
530
+ " Dim x As Integer" ,
531
+ " If Not foo Then" ,
532
+ " x = 1" ,
533
+ " End If" ,
534
+ "End Sub"
535
+ } ;
536
+
537
+ var indenter = new Indenter ( null , ( ) =>
538
+ {
539
+ var s = IndenterSettingsTests . GetMockIndenterSettings ( ) ;
540
+ s . AlignDims = true ;
541
+ return s ;
542
+ } ) ;
543
+ var actual = indenter . Indent ( code , string . Empty ) ;
544
+ Assert . IsTrue ( expected . SequenceEqual ( actual ) ) ;
545
+ }
546
+
547
+ //https://github.com/rubberduck-vba/Rubberduck/issues/2133
548
+ [ TestMethod ]
549
+ [ TestCategory ( "Indenter" ) ]
550
+ public void MultiLineDimWithCommasDontIndentFirstBlockWorks ( )
551
+ {
552
+ var code = new [ ]
553
+ {
554
+ "Public Sub FooBar()" ,
555
+ "Dim foo As Boolean, bar As String _" ,
556
+ ", baz As String _" ,
557
+ ", somethingElse As String" ,
558
+ "Dim x As Integer" ,
559
+ "If Not foo Then" ,
560
+ "x = 1" ,
561
+ "End If" ,
562
+ "End Sub"
563
+ } ;
564
+
565
+ var expected = new [ ]
566
+ {
567
+ "Public Sub FooBar()" ,
568
+ "Dim foo As Boolean, bar As String _" ,
569
+ ", baz As String _" ,
570
+ ", somethingElse As String" ,
571
+ "Dim x As Integer" ,
572
+ " If Not foo Then" ,
573
+ " x = 1" ,
574
+ " End If" ,
575
+ "End Sub"
576
+ } ;
577
+
578
+ var indenter = new Indenter ( null , ( ) =>
579
+ {
580
+ var s = IndenterSettingsTests . GetMockIndenterSettings ( ) ;
581
+ s . IndentFirstDeclarationBlock = false ;
582
+ return s ;
583
+ } ) ;
584
+ var actual = indenter . Indent ( code , string . Empty ) ;
585
+ Assert . IsTrue ( expected . SequenceEqual ( actual ) ) ;
586
+ }
469
587
}
470
588
}
0 commit comments