Skip to content

Commit

Permalink
Merge pull request #64732 from DoctorKrolic/fix-prop-caret-position
Browse files Browse the repository at this point in the history
Fixed prop snippet caret position
  • Loading branch information
akhera99 committed Oct 17, 2022
2 parents a1c6606 + 003b05e commit 048f695
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public async Task InsertPropSnippetInClassTest()
var expectedCodeAfterCommit =
@"class MyClass
{
public int MyProperty {$$ get; set; }
public int MyProperty { get; set; }$$
}";
await VerifyCustomCommitProviderAsync(markupBeforeCommit, ItemToCommit, expectedCodeAfterCommit);
}
Expand All @@ -79,7 +79,7 @@ public async Task InsertPropSnippetInRecordTest()
var expectedCodeAfterCommit =
@"record MyRecord
{
public int MyProperty {$$ get; set; }
public int MyProperty { get; set; }$$
}";
await VerifyCustomCommitProviderAsync(markupBeforeCommit, ItemToCommit, expectedCodeAfterCommit);
}
Expand All @@ -96,7 +96,7 @@ public async Task InsertPropSnippetInStructTest()
var expectedCodeAfterCommit =
@"struct MyStruct
{
public int MyProperty {$$ get; set; }
public int MyProperty { get; set; }$$
}";
await VerifyCustomCommitProviderAsync(markupBeforeCommit, ItemToCommit, expectedCodeAfterCommit);
}
Expand All @@ -113,7 +113,7 @@ public async Task InsertPropSnippetInInterfaceTest()
var expectedCodeAfterCommit =
@"interface MyInterface
{
public int MyProperty {$$ get; set; }
public int MyProperty { get; set; }$$
}";
await VerifyCustomCommitProviderAsync(markupBeforeCommit, ItemToCommit, expectedCodeAfterCommit);
}
Expand All @@ -132,7 +132,7 @@ public async Task InsertPropSnippetNamingTest()
@"class MyClass
{
public int MyProperty { get; set; }
public int MyProperty1 {$$ get; set; }
public int MyProperty1 { get; set; }$$
}";
await VerifyCustomCommitProviderAsync(markupBeforeCommit, ItemToCommit, expectedCodeAfterCommit);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected override async Task<SyntaxNode> GenerateSnippetSyntaxAsync(Document do
protected override int GetTargetCaretPosition(ISyntaxFactsService syntaxFacts, SyntaxNode caretTarget, SourceText sourceText)
{
var propertyDeclaration = (PropertyDeclarationSyntax)caretTarget;
return propertyDeclaration.AccessorList!.OpenBraceToken.Span.End;
return propertyDeclaration.AccessorList!.CloseBraceToken.Span.End;
}

protected override ImmutableArray<SnippetPlaceholder> GetPlaceHolderLocationsList(SyntaxNode node, ISyntaxFacts syntaxFacts, CancellationToken cancellationToken)
Expand Down
3 changes: 0 additions & 3 deletions src/Features/Core/Portable/Snippets/SnippetPlaceholder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Text;
using Microsoft.CodeAnalysis.Text;

namespace Microsoft.CodeAnalysis.Snippets
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.LanguageService;
using Microsoft.CodeAnalysis.Text;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.Text;

namespace Microsoft.CodeAnalysis.Snippets.SnippetProviders
{
Expand Down

0 comments on commit 048f695

Please sign in to comment.