Skip to content

Commit

Permalink
removed fluff
Browse files Browse the repository at this point in the history
  • Loading branch information
retailcoder committed Jun 4, 2018
1 parent ddb2993 commit 2406009
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
6 changes: 1 addition & 5 deletions Rubberduck.Core/AutoComplete/AutoCompleteBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,19 @@ protected AutoCompleteBase(string inputToken, string outputToken)
public string InputToken { get; }
public string OutputToken { get; }

private bool _executing;

public virtual bool Execute(AutoCompleteEventArgs e)
{
var selection = e.CodePane.Selection;
if (_executing || selection.StartColumn < 2) { return false; }
if (selection.StartColumn < 2) { return false; }

if (!e.IsCommitted && e.OldCode.Substring(selection.StartColumn - 2, 1) == InputToken)
{
using (var module = e.CodePane.CodeModule)
{
_executing = true;
var newCode = e.OldCode.Insert(selection.StartColumn - 1, OutputToken);
module.ReplaceLine(e.CodePane.Selection.StartLine, newCode);
e.CodePane.Selection = selection;
e.NewCode = newCode;
_executing = false;
return true;
}
}
Expand Down
6 changes: 1 addition & 5 deletions Rubberduck.Core/AutoComplete/AutoCompleteBlockBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ protected AutoCompleteBlockBase(IIndenterSettings indenterSettings, string input

protected virtual bool IndentBody => true;

private bool _executing;
public override bool Execute(AutoCompleteEventArgs e)
{
if (_executing || (SkipPreCompilerDirective && e.OldCode.Trim().StartsWith("#")))
if (SkipPreCompilerDirective && e.OldCode.Trim().StartsWith("#"))
{
return false;
}
Expand All @@ -51,11 +50,9 @@ public override bool Execute(AutoCompleteEventArgs e)
var indent = e.OldCode.TakeWhile(c => char.IsWhiteSpace(c)).Count();
using (var module = e.CodePane.CodeModule)
{
_executing = true;
var code = OutputToken.PadLeft(OutputToken.Length + indent, ' ');
if (module.GetLines(selection.NextLine) == code)
{
_executing = false;
return false;
}

Expand All @@ -65,7 +62,6 @@ public override bool Execute(AutoCompleteEventArgs e)
e.CodePane.Selection = new VBEditor.Selection(selection.StartLine, indent + stdIndent + 1);

e.NewCode = e.OldCode;
_executing = false;
return true;
}
}
Expand Down

0 comments on commit 2406009

Please sign in to comment.