Skip to content

Commit 96392cc

Browse files
committed
Fix regression when caret is at the opening on and XML tag
1 parent f7dabe1 commit 96392cc

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

src/Features/CSharpTest/ReplaceDocCommentTextWithTag/ReplaceDocCommentTextWithTagTests.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,25 @@ class C<TKey>
9494
""");
9595
}
9696

97+
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/76548")]
98+
public async Task TestEndOfKeyword_XmlOpenTagPreceding()
99+
{
100+
await TestInRegularAndScriptAsync(
101+
"""
102+
/// <summary>[||]null is an option.</summary>
103+
class C<TKey>
104+
{
105+
}
106+
""",
107+
108+
"""
109+
/// <summary><see langword="null"/> is an option.</summary>
110+
class C<TKey>
111+
{
112+
}
113+
""");
114+
}
115+
97116
[Fact]
98117
public async Task TestSelectedKeyword()
99118
{

src/Features/Core/Portable/ReplaceDocCommentTextWithTag/AbstractReplaceDocCommentTextWithTagCodeRefactoringProvider.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte
2525
{
2626
var (document, span, cancellationToken) = context;
2727
var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
28-
var token = root.FindTokenFromEnd(span.Start, findInsideTrivia: true);
28+
var token = root.FindToken(span.Start, findInsideTrivia: true);
2929

3030
if (!IsXmlTextToken(token))
31-
return;
31+
{
32+
token = root.FindTokenFromEnd(span.Start, findInsideTrivia: true);
33+
if (!IsXmlTextToken(token))
34+
{
35+
return;
36+
}
37+
}
3238

3339
if (!token.FullSpan.Contains(span))
3440
return;

src/Features/VisualBasicTest/ReplaceDocCommentTextWithTag/ReplaceDocCommentTextWithTagTests.vb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,19 @@ class C(Of TKey)
8181
end class")
8282
End Function
8383

84+
<Fact, WorkItem("https://github.com/dotnet/roslyn/issues/76548")>
85+
Public Async Function TestEndOfKeyword_XmlOpenTagPreceding() As Task
86+
Await TestInRegularAndScriptAsync(
87+
"
88+
''' <summary>[||]MustInherit is a thing</summary>
89+
class C(Of TKey)
90+
end class",
91+
"
92+
''' <summary>[||]<see langword=""MustInherit""/> is a thing</summary>
93+
class C(Of TKey)
94+
end class")
95+
End Function
96+
8497
<Fact>
8598
Public Async Function TestSelectedKeyword() As Task
8699
Await TestInRegularAndScriptAsync(

0 commit comments

Comments
 (0)