Skip to content

Commit 92beed1

Browse files
committed
added unit test for Call statement SCP
1 parent bf1840e commit 92beed1

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Rubberduck.Core/AutoComplete/Service/SelfClosingPairHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private bool HandleInternal(AutoCompleteEventArgs e, CodeString original, SelfCl
110110
}
111111

112112
var reprettified = CodePaneHandler.Prettify(e.Module, result);
113-
if (pair.OpeningChar == '(' && !reprettified.Equals(result))
113+
if (pair.OpeningChar == '(' && e.Character == pair.OpeningChar && !reprettified.Equals(result))
114114
{
115115
// VBE eats it. bail out but don't swallow the keypress.
116116
e.Handled = false;
@@ -130,7 +130,7 @@ private bool HandleInternal(AutoCompleteEventArgs e, CodeString original, SelfCl
130130
e.Character == pair.OpeningChar &&
131131
!result.CaretLine.EndsWith($"{pair.OpeningChar}{pair.ClosingChar}"))
132132
{
133-
// VBE eats it. bail out but still swallow the keypress, since we've already re-prettified.
133+
// VBE eats it. bail out but still swallow the keypress.
134134
e.Handled = true;
135135
result = null;
136136
return false;

RubberduckTests/AutoComplete/SelfClosingPairHandlerTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ public void GivenOpeningParenthesisOnOtherwiseNonEmptyLine_ReturnsFalseAndSwallo
103103
Assert.IsTrue(info.Args.Handled);
104104
}
105105

106+
[Test]
107+
public void GivenOpeningParenthesisOnCallStatement_ReturnsFalseAndLetsKeypressThrough()
108+
{
109+
var input = '(';
110+
var original = "Call DoSomething|".ToCodeString();
111+
var rePrettified = "Call DoSomething|".ToCodeString();
112+
var info = new SelfClosingPairTestInfo(original, input, rePrettified);
113+
114+
Assert.IsFalse(Run(info));
115+
Assert.IsFalse(info.Args.Handled);
116+
}
106117
[Test]
107118
public void GivenBackspaceOnMatchedPair_DeletesMatchingTokens()
108119
{

0 commit comments

Comments
 (0)