提交 522e1e0d 编写于 作者: B Balaji Krishnan

Merge pull request #8184 from balajikris/CloseParenTypeOverVB

Bug Fix 5607: VB Parenthesis overtyping
......@@ -109,7 +109,7 @@ internal void CheckReturnOnNonEmptyLine(IBraceCompletionSession session, int exp
internal void CheckOverType(IBraceCompletionSession session, bool allowOverType = true)
{
var preClosingPoint = session.ClosingPoint.GetPoint(session.SubjectBuffer.CurrentSnapshot);
Assert.Equal(preClosingPoint.Subtract(1).GetChar(), session.ClosingBrace);
Assert.Equal(session.ClosingBrace, preClosingPoint.Subtract(1).GetChar());
bool handled;
session.PreOverType(out handled);
......
......@@ -301,6 +301,58 @@ End Class</code>
End Using
End Function
<WorkItem(5607, "https://github.com/dotnet/roslyn/issues/5607")>
<WpfFact, Trait(Traits.Feature, Traits.Features.AutomaticCompletion)>
Public Async Function TestOverTypeAfterIntegerLiteral() As Task
Dim code = <code>Imports System.Collections.Generic
Class C
Sub Method()
Dim lines As New List(Of String)
lines.RemoveAt$$
End Sub
End Class</code>
Using session = Await CreateSessionAsync(code)
Assert.NotNull(session)
CheckStart(session.Session)
Type(session.Session, "0")
CheckOverType(session.Session)
End Using
End Function
<WorkItem(5607, "https://github.com/dotnet/roslyn/issues/5607")>
<WpfFact, Trait(Traits.Feature, Traits.Features.AutomaticCompletion)>
Public Async Function TestOverTypeAfterDateLiteral() As Task
Dim code = <code>Class C
Sub Method()
Test(#1AM#)$$
End Sub
Sub Test(d As Date)
End Sub
End Class</code>
Using session = Await CreateSessionAsync(code)
Assert.NotNull(session)
CheckOverType(session.Session)
End Using
End Function
<WpfFact, Trait(Traits.Feature, Traits.Features.AutomaticCompletion)>
Public Async Function TestOverTypeAfterStringLiteral() As Task
Dim code = <code>Class C
Sub Method()
Console.Write$$
End Sub
End Class</code>
Using session = Await CreateSessionAsync(code)
Assert.NotNull(session)
CheckStart(session.Session)
Type(session.Session, """a""")
CheckOverType(session.Session)
End Using
End Function
Friend Overloads Function CreateSessionAsync(code As XElement) As Threading.Tasks.Task(Of Holder)
Return CreateSessionAsync(code.NormalizedValue())
End Function
......
......@@ -114,6 +114,13 @@ recurse:
Return True
End If
' If it is a numeric literal, all checks are done and we're okay.
If token.IsKind(SyntaxKind.IntegerLiteralToken, SyntaxKind.DecimalLiteralToken,
SyntaxKind.DateLiteralToken, SyntaxKind.FloatingLiteralToken) Then
Return False
End If
' For char or string literals, check if we're at the end of an incomplete literal.
Dim lastChar = If(token.IsKind(SyntaxKind.CharacterLiteralToken), "'", """")
Return AtEndOfIncompleteStringOrCharLiteral(token, position, lastChar)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册