From 411ce4de35131cb5fbae7cefcf9b586082aeecef Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Sat, 17 Apr 2021 19:02:01 +0200 Subject: [PATCH 1/3] Support record structs in complete statement command --- .../CompleteStatement/CompleteStatementCommandHandler.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/EditorFeatures/CSharp/CompleteStatement/CompleteStatementCommandHandler.cs b/src/EditorFeatures/CSharp/CompleteStatement/CompleteStatementCommandHandler.cs index 42f9e1ce8bf4..7417978368bb 100644 --- a/src/EditorFeatures/CSharp/CompleteStatement/CompleteStatementCommandHandler.cs +++ b/src/EditorFeatures/CSharp/CompleteStatement/CompleteStatementCommandHandler.cs @@ -246,7 +246,8 @@ private static bool CanHaveSemicolon(SyntaxNode currentNode) return true; } - if (currentNode is RecordDeclarationSyntax { OpenBraceToken: { IsMissing: true } }) + if (currentNode is RecordDeclarationSyntax { OpenBraceToken: { IsMissing: true } } || + currentNode is RecordStructDeclarationSyntax { OpenBraceToken: { IsMissing: true } }) { return true; } @@ -333,6 +334,7 @@ private static bool TryGetCaretPositionToMove(SyntaxNode statementNode, Snapshot case SyntaxKind.ArrowExpressionClause: case SyntaxKind.MethodDeclaration: case SyntaxKind.RecordDeclaration: + case SyntaxKind.RecordStructDeclaration: // These statement types end in a semicolon. // if the original caret was inside any delimiters, `caret` will be after the outermost delimiter targetPosition = caret; From 626fc66a28e29717dbe3866ba63b87d100d36e2d Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Sat, 17 Apr 2021 19:03:05 +0200 Subject: [PATCH 2/3] Update CSharpCompleteStatementCommandHandlerTests.cs --- .../CSharpCompleteStatementCommandHandlerTests.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/EditorFeatures/CSharpTest/CompleteStatement/CSharpCompleteStatementCommandHandlerTests.cs b/src/EditorFeatures/CSharpTest/CompleteStatement/CSharpCompleteStatementCommandHandlerTests.cs index 59113b9e53a0..fca445bce63c 100644 --- a/src/EditorFeatures/CSharpTest/CompleteStatement/CSharpCompleteStatementCommandHandlerTests.cs +++ b/src/EditorFeatures/CSharpTest/CompleteStatement/CSharpCompleteStatementCommandHandlerTests.cs @@ -55,6 +55,8 @@ internal static int MethodM(int a, int b) [InlineData("public record C(int X, $$int Y)", "public record C(int X, int Y)")] [InlineData("public record C(int X, int$$ Y)", "public record C(int X, int Y)")] [InlineData("public record C(int X, int Y$$)", "public record C(int X, int Y)")] + [InlineData("public record class C(int X, int Y$$)", "public record class C(int X, int Y)")] + [InlineData("public record struct C(int X, int Y$$)", "public record struct C(int X, int Y)")] public void ParameterList_CouldBeHandled(string signature, string expectedSignature) { var code = $@" From 4c351d8ed851de761a8028f54a1a88cc132424e6 Mon Sep 17 00:00:00 2001 From: Youssef Victor Date: Thu, 22 Apr 2021 10:48:42 +0200 Subject: [PATCH 3/3] Fix --- .../CompleteStatement/CompleteStatementCommandHandler.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/EditorFeatures/CSharp/CompleteStatement/CompleteStatementCommandHandler.cs b/src/EditorFeatures/CSharp/CompleteStatement/CompleteStatementCommandHandler.cs index 7417978368bb..03e63c314a90 100644 --- a/src/EditorFeatures/CSharp/CompleteStatement/CompleteStatementCommandHandler.cs +++ b/src/EditorFeatures/CSharp/CompleteStatement/CompleteStatementCommandHandler.cs @@ -246,8 +246,7 @@ private static bool CanHaveSemicolon(SyntaxNode currentNode) return true; } - if (currentNode is RecordDeclarationSyntax { OpenBraceToken: { IsMissing: true } } || - currentNode is RecordStructDeclarationSyntax { OpenBraceToken: { IsMissing: true } }) + if (currentNode is RecordDeclarationSyntax { OpenBraceToken: { IsMissing: true } }) { return true; }