Skip to content

Commit

Permalink
Fix mixed case in automatic line ending
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi committed Nov 22, 2024
1 parent 45e24db commit ea5386f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@

namespace Microsoft.CodeAnalysis.Editor.CSharp.AutomaticCompletion;

/// <summary>
/// csharp automatic line ender command handler
/// </summary>
[Export(typeof(ICommandHandler))]
[ContentType(ContentTypeNames.CSharpContentType)]
[Name(PredefinedCommandHandlerNames.AutomaticLineEnder)]
Expand Down Expand Up @@ -324,18 +321,18 @@ protected override void ModifySelectedNode(
{
// For these syntax node, braces pair could be easily added by modify the syntax tree
if (selectedNode is BaseTypeDeclarationSyntax
or BaseMethodDeclarationSyntax
or LocalFunctionStatementSyntax
or AccessorDeclarationSyntax
or ObjectCreationExpressionSyntax
or WhileStatementSyntax
or ForEachStatementSyntax
or ForStatementSyntax
or LockStatementSyntax
or UsingStatementSyntax
or DoStatementSyntax
or IfStatementSyntax
or ElseClauseSyntax)
or BaseMethodDeclarationSyntax
or LocalFunctionStatementSyntax
or AccessorDeclarationSyntax
or ObjectCreationExpressionSyntax
or WhileStatementSyntax
or CommonForEachStatementSyntax
or ForStatementSyntax
or LockStatementSyntax
or UsingStatementSyntax
or DoStatementSyntax
or IfStatementSyntax
or ElseClauseSyntax)
{
// Add the braces and get the next caretPosition
var (newRoot, nextCaretPosition) = AddBraceToSelectedNode(document.SolutionServices, document.Root, selectedNode, formattingOptions, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ private static SyntaxNode AddBlockToEmbeddedStatementOwner(
return embeddedStatementOwner switch
{
DoStatementSyntax doStatementNode => doStatementNode.WithStatement(block),
ForEachStatementSyntax forEachStatementNode => forEachStatementNode.WithStatement(block),
CommonForEachStatementSyntax forEachStatementNode => forEachStatementNode.WithStatement(block),
ForStatementSyntax forStatementNode => forStatementNode.WithStatement(block),
IfStatementSyntax ifStatementNode => ifStatementNode.WithStatement(block),
ElseClauseSyntax elseClauseNode => elseClauseNode.WithStatement(block),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable

using System;
using Microsoft.CodeAnalysis.Editor.CSharp.AutomaticCompletion;
using Microsoft.CodeAnalysis.Editor.UnitTests.AutomaticCompletion;
Expand All @@ -16,7 +14,7 @@
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.AutomaticCompletion;

[Trait(Traits.Feature, Traits.Features.AutomaticCompletion)]
public class AutomaticLineEnderTests : AbstractAutomaticLineEnderTests
public sealed class AutomaticLineEnderTests : AbstractAutomaticLineEnderTests
{
[WpfFact]
public void Creation()
Expand Down Expand Up @@ -609,7 +607,7 @@ object goo(object o)
}

[WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530352")]
public void EmbededStatement3()
public void EmbeddedStatement3()
{
Test(@"class Program
{
Expand All @@ -629,6 +627,27 @@ void Method()
}");
}

[WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530352")]
public void EmbeddedStatement4()
{
Test(@"class Program
{
void Method()
{
foreach (var (x, y) in z)
{
$$
}
}
}", @"class Program
{
void Method()
{
foreach (var (x, y) in z$$)
}
}");
}

[WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530716")]
public void DoNotAssertOnMultilineToken()
{
Expand Down

0 comments on commit ea5386f

Please sign in to comment.