File tree 3 files changed +24
-2
lines changed
RubberduckTests/SmartIndenter
3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ public class AbsoluteCodeLine
16
16
17
17
private static readonly Regex PropertyStartRegex = new Regex ( @"^(Public\s|Private\s|Friend\s)?(Static\s)?(Property\s(Let|Get|Set))\s" , RegexOptions . IgnoreCase ) ;
18
18
19
- private static readonly Regex ProcedureStartIgnoreRegex = new Regex ( @"^[LR]?Set\s|^Let\s|^(Public|Private)\sDeclare\s (Function|Sub)" , RegexOptions . IgnoreCase ) ;
19
+ private static readonly Regex ProcedureStartIgnoreRegex = new Regex ( @"^[LR]?Set\s|^Let\s|^(Public\s |Private\s)?Declare\s(PtrSafe\s)? (Function|Sub)" , RegexOptions . IgnoreCase ) ;
20
20
private static readonly Regex ProcedureEndRegex = new Regex ( @"^End\s(Sub|Function|Property)" , RegexOptions . IgnoreCase ) ;
21
21
private static readonly Regex TypeEnumStartRegex = new Regex ( @"^(Public\s|Private\s)?(Enum\s|Type\s)" , RegexOptions . IgnoreCase ) ;
22
22
private static readonly Regex TypeEnumEndRegex = new Regex ( @"^End\s(Enum|Type)" , RegexOptions . IgnoreCase ) ;
Original file line number Diff line number Diff line change @@ -202,7 +202,7 @@ public override string ToString()
202
202
return _lines . Aggregate ( string . Empty , ( x , y ) => x + y . ToString ( ) ) ;
203
203
}
204
204
205
- private static readonly Regex StartIgnoreRegex = new Regex ( @"^(\d*\s)?\s*[LR]?Set\s|^(\d*\s)?\s*Let\s|^(\d*\s)?\s*(Public|Private)\sDeclare\s (Function|Sub)|^(\d*\s+)" , RegexOptions . IgnoreCase ) ;
205
+ private static readonly Regex StartIgnoreRegex = new Regex ( @"^(\d*\s)?\s*[LR]?Set\s|^(\d*\s)?\s*Let\s|^(\d*\s)?\s*(Public\s |Private\s)?Declare\s(PtrSafe\s)? (Function|Sub)|^(\d*\s+)" , RegexOptions . IgnoreCase ) ;
206
206
private readonly Stack < AlignmentToken > _alignment = new Stack < AlignmentToken > ( ) ;
207
207
private int _nestingDepth ;
208
208
Original file line number Diff line number Diff line change @@ -29,6 +29,28 @@ public void DeclarationLineAlignsCorrectly()
29
29
Assert . IsTrue ( expected . SequenceEqual ( actual ) ) ;
30
30
}
31
31
32
+ // https://github.com/rubberduck-vba/Rubberduck/issues/4795
33
+ [ Test ]
34
+ [ Category ( "Indenter" ) ]
35
+ public void DeclarationPtrSafeLineAlignsCorrectly ( )
36
+ {
37
+ var code = new [ ]
38
+ {
39
+ @"Private Declare PtrSafe Function Foo Lib ""bar.dll"" _" ,
40
+ "(x As Long y As Long) As LongPtr"
41
+ } ;
42
+
43
+ var expected = new [ ]
44
+ {
45
+ @"Private Declare PtrSafe Function Foo Lib ""bar.dll"" _" ,
46
+ " (x As Long y As Long) As LongPtr"
47
+ } ;
48
+
49
+ var indenter = new Indenter ( null , ( ) => IndenterSettingsTests . GetMockIndenterSettings ( ) ) ;
50
+ var actual = indenter . Indent ( code ) ;
51
+ Assert . IsTrue ( expected . SequenceEqual ( actual ) ) ;
52
+ }
53
+
32
54
[ Test ]
33
55
[ Category ( "Indenter" ) ]
34
56
public void FunctionParametersAlignCorrectly ( )
You can’t perform that action at this time.
0 commit comments