Skip to content

Commit e0db8d1

Browse files
committed
Test updates
1 parent 10095a5 commit e0db8d1

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/Razor/test/Microsoft.AspNetCore.Razor.LanguageServer.Test/CodeActions/Razor/ExtractToNewComponentCodeActionProviderTest.cs

+21-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
// Licensed under the MIT license. See License.txt in the project root for license information.
33

44
using System;
5-
using System.Collections.Generic;
6-
using System.Collections.Immutable;
7-
using System.Linq;
8-
using System.Text;
95
using System.Text.Json;
106
using System.Threading.Tasks;
117
using Microsoft.AspNetCore.Razor.Language;
@@ -179,8 +175,8 @@ public async Task Handle_MultiPointSelectionWithEndAfterElement_ReturnsCurrentEl
179175
<PageTitle>Home</PageTitle>
180176
181177
<div id="parent">
182-
[|<div>
183-
$$<h1>Div a title</h1>
178+
[|$$<div>
179+
<h1>Div a title</h1>
184180
<p>Div a par</p>
185181
</div>
186182
<div>
@@ -205,6 +201,8 @@ public async Task Handle_MultiPointSelectionWithEndAfterElement_ReturnsCurrentEl
205201
var location = new SourceLocation(cursorPosition, -1, -1);
206202
var context = CreateRazorCodeActionContext(request, location, documentPath, contents);
207203

204+
AddMultiPointSelectionToContext(ref context, selectionSpan);
205+
208206
var provider = new ExtractToNewComponentCodeActionProvider(LoggerFactory);
209207

210208
// Act
@@ -250,4 +248,21 @@ private static RazorCodeActionContext CreateRazorCodeActionContext(VSCodeActionP
250248

251249
return context;
252250
}
251+
252+
253+
private static void AddMultiPointSelectionToContext(ref RazorCodeActionContext context, TextSpan selectionSpan)
254+
{
255+
var sourceText = context.CodeDocument.GetSourceText();
256+
var startLinePosition = sourceText.Lines.GetLinePosition(selectionSpan.Start);
257+
var startPosition = new Position(startLinePosition.Line, startLinePosition.Character);
258+
259+
var endLinePosition = sourceText.Lines.GetLinePosition(selectionSpan.End);
260+
var endPosition = new Position(endLinePosition.Line, endLinePosition.Character);
261+
262+
context.Request.Range = new Range
263+
{
264+
Start = startPosition,
265+
End = endPosition
266+
};
267+
}
253268
}

0 commit comments

Comments
 (0)