@@ -9,6 +9,8 @@ namespace Rubberduck.SmartIndenter
9
9
/// </summary>
10
10
public class SimpleIndenter : ISimpleIndenter
11
11
{
12
+ protected virtual Func < IIndenterSettings > Settings { get ; }
13
+
12
14
/// <summary>
13
15
/// Indents the code contained in the passed string. NOTE: In Rubberduck this overload should only be used on procedures or modules.
14
16
/// </summary>
@@ -17,23 +19,23 @@ public class SimpleIndenter : ISimpleIndenter
17
19
/// </remarks>
18
20
/// <param name="code">The code block to indent</param>
19
21
/// <returns>Indented code lines</returns>
20
- public IEnumerable < string > Indent ( string code , IIndenterSettings settings = null ) => Indent ( code . Replace ( "\r " , string . Empty ) . Split ( '\n ' ) , false , settings ) ;
22
+ public IEnumerable < string > Indent ( string code , IIndenterSettings settings = null ) => Indent ( code . Replace ( "\r " , string . Empty ) . Split ( '\n ' ) , false , settings ?? Settings ? . Invoke ( ) ) ;
21
23
22
24
/// <summary>
23
25
/// Indents a range of code lines. NOTE: If inserting procedures, use the forceTrailingNewLines overload to preserve vertical spacing in the module.
24
26
/// Do not call directly on selections. Use Indent(IVBComponent, Selection) instead.
25
27
/// </summary>
26
28
/// <param name="codeLines">Code lines to indent</param>
27
29
/// <returns>Indented code lines</returns>
28
- public IEnumerable < string > Indent ( IEnumerable < string > codeLines , IIndenterSettings settings = null ) => Indent ( codeLines , false , settings ) ;
30
+ public IEnumerable < string > Indent ( IEnumerable < string > codeLines , IIndenterSettings settings = null ) => Indent ( codeLines , false , settings ?? Settings ? . Invoke ( ) ) ;
29
31
30
32
/// <summary>
31
33
/// Indents a range of code lines. Do not call directly on selections. Use Indent(IVBComponent, Selection) instead.
32
34
/// </summary>
33
35
/// <param name="codeLines">Code lines to indent</param>
34
36
/// <param name="forceTrailingNewLines">If true adds a number of blank lines after the last procedure based on VerticallySpaceProcedures settings</param>
35
37
/// <returns>Indented code lines</returns>
36
- public IEnumerable < string > Indent ( IEnumerable < string > codeLines , bool forceTrailingNewLines , IIndenterSettings settings = null ) => Indent ( codeLines , forceTrailingNewLines , false , settings ) ;
38
+ public IEnumerable < string > Indent ( IEnumerable < string > codeLines , bool forceTrailingNewLines , IIndenterSettings settings = null ) => Indent ( codeLines , forceTrailingNewLines , false , settings ?? Settings ? . Invoke ( ) ) ;
37
39
38
40
protected IEnumerable < string > Indent ( IEnumerable < string > codeLines , bool forceTrailingNewLines , bool procedure , IIndenterSettings settings )
39
41
{
0 commit comments