Skip to content

Commit

Permalink
fix block completion
Browse files Browse the repository at this point in the history
  • Loading branch information
retailcoder committed Jun 23, 2018
1 parent d45c1c7 commit 138677c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions Rubberduck.Core/AutoComplete/AutoCompleteBlockBase.cs
Expand Up @@ -62,7 +62,7 @@ public override bool Execute(AutoCompleteEventArgs e, AutoCompleteSettings setti

if (IsMatch(code) && !IsBlockCompleted(module, selection))
{
var indent = code.TakeWhile(c => char.IsWhiteSpace(c)).Count();
var indent = originalCode.TakeWhile(c => char.IsWhiteSpace(c)).Count();
var newCode = OutputToken.PadLeft(OutputToken.Length + indent, ' ');

var stdIndent = IndentBody
Expand Down Expand Up @@ -99,9 +99,8 @@ public override bool IsMatch(string code)
regexOk = Regex.IsMatch(code, pattern, RegexOptions.IgnoreCase);
}

return regexOk &&
code.HasComment(out int commentIndex) &&
code.IndexOf(InputToken) < commentIndex;
var hasComment = code.HasComment(out int commentIndex);
return regexOk && (!hasComment || code.IndexOf(InputToken) < commentIndex);
}

private bool IsBlockCompleted(ICodeModule module, Selection selection)
Expand Down

0 comments on commit 138677c

Please sign in to comment.