@@ -8,25 +8,24 @@ namespace Rubberduck.AutoComplete
88{
99 public abstract class AutoCompleteBlockBase : AutoCompleteBase
1010 {
11- /// <param name="api">Used for ensuring compilable resulting code.</param>
1211 /// <param name="indenterSettings">Used for auto-indenting blocks as per indenter settings.</param>
1312 /// <param name="inputToken">The token that starts the block, i.e. what to detect.</param>
1413 /// <param name="outputToken">The token that closes the block, i.e. what to insert.</param>
15- protected AutoCompleteBlockBase ( IVBETypeLibsAPI api , IIndenterSettings indenterSettings , string inputToken , string outputToken )
14+ protected AutoCompleteBlockBase ( IIndenterSettings indenterSettings , string inputToken , string outputToken )
1615 : base ( inputToken , outputToken )
1716 {
18- _api = api ;
19- _indenterSettings = indenterSettings ;
17+ IndenterSettings = indenterSettings ;
2018 }
2119
2220 protected virtual bool FindInputTokenAtBeginningOfCurrentLine => false ;
2321
24- private readonly IVBETypeLibsAPI _api ;
25- private readonly IIndenterSettings _indenterSettings ;
22+ protected readonly IIndenterSettings IndenterSettings ;
2623
2724 protected virtual bool ExecuteOnCommittedInputOnly => true ;
2825 protected virtual bool MatchInputTokenAtEndOfLineOnly => false ;
2926
27+ protected virtual bool IndentBody => true ;
28+
3029 private bool _executing ;
3130 public override bool Execute ( AutoCompleteEventArgs e )
3231 {
@@ -36,7 +35,7 @@ public override bool Execute(AutoCompleteEventArgs e)
3635 }
3736
3837 var selection = e . CodePane . Selection ;
39- var stdIndent = _indenterSettings . IndentSpaces ;
38+ var stdIndent = IndentBody ? IndenterSettings . IndentSpaces : 0 ;
4039
4140 var isMatch = MatchInputTokenAtEndOfLineOnly
4241 ? e . OldCode . EndsWith ( InputToken )
@@ -59,6 +58,7 @@ public override bool Execute(AutoCompleteEventArgs e)
5958
6059 module . ReplaceLine ( selection . StartLine , new string ( ' ' , indent + stdIndent ) ) ;
6160 e . CodePane . Selection = new VBEditor . Selection ( selection . StartLine , indent + stdIndent + 1 ) ;
61+
6262 e . NewCode = e . OldCode ;
6363 _executing = false ;
6464 return true ;
0 commit comments