Skip to content

Commit

Permalink
Test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
marcarro committed Jul 30, 2024
1 parent 10095a5 commit e0db8d1
Showing 1 changed file with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
// Licensed under the MIT license. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Razor.Language;
Expand Down Expand Up @@ -179,8 +175,8 @@ public async Task Handle_MultiPointSelectionWithEndAfterElement_ReturnsCurrentEl
<PageTitle>Home</PageTitle>

<div id="parent">
[|<div>
$$<h1>Div a title</h1>
[|$$<div>
<h1>Div a title</h1>
<p>Div a par</p>
</div>
<div>
Expand All @@ -205,6 +201,8 @@ public async Task Handle_MultiPointSelectionWithEndAfterElement_ReturnsCurrentEl
var location = new SourceLocation(cursorPosition, -1, -1);
var context = CreateRazorCodeActionContext(request, location, documentPath, contents);

AddMultiPointSelectionToContext(ref context, selectionSpan);

var provider = new ExtractToNewComponentCodeActionProvider(LoggerFactory);

// Act
Expand Down Expand Up @@ -250,4 +248,21 @@ private static RazorCodeActionContext CreateRazorCodeActionContext(VSCodeActionP

return context;
}


private static void AddMultiPointSelectionToContext(ref RazorCodeActionContext context, TextSpan selectionSpan)
{
var sourceText = context.CodeDocument.GetSourceText();
var startLinePosition = sourceText.Lines.GetLinePosition(selectionSpan.Start);
var startPosition = new Position(startLinePosition.Line, startLinePosition.Character);

var endLinePosition = sourceText.Lines.GetLinePosition(selectionSpan.End);
var endPosition = new Position(endLinePosition.Line, endLinePosition.Character);

context.Request.Range = new Range
{
Start = startPosition,
End = endPosition
};
}
}

0 comments on commit e0db8d1

Please sign in to comment.