@@ -12,28 +12,21 @@ public abstract class AutoCompleteBlockBase : AutoCompleteBase
1212 /// <param name="indenterSettings">Used for auto-indenting blocks as per indenter settings.</param>
1313 /// <param name="inputToken">The token that starts the block, i.e. what to detect.</param>
1414 /// <param name="outputToken">The token that closes the block, i.e. what to insert.</param>
15- /// <param name="committedOnly">Indicates whether line of code was committed, i.e. selection is on the line underneath the code string.</param>
16- protected AutoCompleteBlockBase ( IVBETypeLibsAPI api , IIndenterSettings indenterSettings , string inputToken , string outputToken , bool committedOnly = true )
15+ protected AutoCompleteBlockBase ( IVBETypeLibsAPI api , IIndenterSettings indenterSettings , string inputToken , string outputToken )
1716 : base ( inputToken , outputToken )
1817 {
1918 _api = api ;
2019 _indenterSettings = indenterSettings ;
21- _committedOnly = committedOnly ;
2220 }
2321
2422 protected virtual bool FindInputTokenAtBeginningOfCurrentLine => false ;
2523
2624 private readonly IVBETypeLibsAPI _api ;
2725 private readonly IIndenterSettings _indenterSettings ;
28- private readonly bool _committedOnly ;
2926
3027 protected virtual bool ExecuteOnCommittedInputOnly => true ;
3128 protected virtual bool MatchInputTokenAtEndOfLineOnly => false ;
3229
33- private string _pattern => MatchInputTokenAtEndOfLineOnly
34- ? $ "\\ b{ InputToken } \\ r\\ n$"
35- : $ "\\ b{ InputToken } \\ b";
36-
3730 private bool _executing ;
3831 public override bool Execute ( AutoCompleteEventArgs e )
3932 {
@@ -45,7 +38,11 @@ public override bool Execute(AutoCompleteEventArgs e)
4538 var selection = e . CodePane . Selection ;
4639 var stdIndent = _indenterSettings . IndentSpaces ;
4740
48- if ( ( ! _committedOnly || e . IsCommitted ) && Regex . IsMatch ( e . OldCode . Trim ( ) , _pattern ) )
41+ var isMatch = MatchInputTokenAtEndOfLineOnly
42+ ? e . OldCode . EndsWith ( InputToken )
43+ : Regex . IsMatch ( e . OldCode . Trim ( ) , $ "\\ b{ InputToken } \\ b") ;
44+
45+ if ( isMatch && ( ! ExecuteOnCommittedInputOnly || e . IsCommitted ) )
4946 {
5047 var indent = e . OldCode . TakeWhile ( c => char . IsWhiteSpace ( c ) ) . Count ( ) ;
5148 using ( var module = e . CodePane . CodeModule )
@@ -54,6 +51,7 @@ public override bool Execute(AutoCompleteEventArgs e)
5451 var code = OutputToken . PadLeft ( OutputToken . Length + indent , ' ' ) ;
5552 if ( module . GetLines ( selection . NextLine ) == code )
5653 {
54+ _executing = false ;
5755 return false ;
5856 }
5957
0 commit comments