File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed
RubberduckTests/SmartIndenter Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ public class AbsoluteCodeLine
1616
1717 private static readonly Regex PropertyStartRegex = new Regex ( @"^(Public\s|Private\s|Friend\s)?(Static\s)?(Property\s(Let|Get|Set))\s" , RegexOptions . IgnoreCase ) ;
1818
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 ) ;
2020 private static readonly Regex ProcedureEndRegex = new Regex ( @"^End\s(Sub|Function|Property)" , RegexOptions . IgnoreCase ) ;
2121 private static readonly Regex TypeEnumStartRegex = new Regex ( @"^(Public\s|Private\s)?(Enum\s|Type\s)" , RegexOptions . IgnoreCase ) ;
2222 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()
202202 return _lines . Aggregate ( string . Empty , ( x , y ) => x + y . ToString ( ) ) ;
203203 }
204204
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 ) ;
206206 private readonly Stack < AlignmentToken > _alignment = new Stack < AlignmentToken > ( ) ;
207207 private int _nestingDepth ;
208208
Original file line number Diff line number Diff line change @@ -29,6 +29,28 @@ public void DeclarationLineAlignsCorrectly()
2929 Assert . IsTrue ( expected . SequenceEqual ( actual ) ) ;
3030 }
3131
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+
3254 [ Test ]
3355 [ Category ( "Indenter" ) ]
3456 public void FunctionParametersAlignCorrectly ( )
You can’t perform that action at this time.
0 commit comments