@@ -189,7 +189,7 @@ private static SelectionAnalysisResult TryAnalyzeSelection(RazorCodeDocument cod
189
189
190
190
endElementNode ??= startElementNode ;
191
191
192
- var success = TryProcessMultiPointSelection ( startElementNode ,
192
+ var success = TryProcessSelection ( startElementNode ,
193
193
endElementNode ,
194
194
codeDocument ,
195
195
actionParams ,
@@ -267,7 +267,7 @@ private static (MarkupSyntaxNode? Start, MarkupSyntaxNode? End) GetStartAndEndEl
267
267
}
268
268
269
269
// Correct selection to include the current node if the selection ends at the "edge" (i.e. immediately after the ">") of a tag.
270
- if ( string . IsNullOrWhiteSpace ( endOwner . ToFullString ( ) ) && endOwner . TryGetPreviousSibling ( out var previousSibling ) )
270
+ if ( endOwner is MarkupTextLiteralSyntax && endOwner . ContainsOnlyWhitespace ( ) && endOwner . TryGetPreviousSibling ( out var previousSibling ) )
271
271
{
272
272
endOwner = previousSibling ;
273
273
}
@@ -286,16 +286,16 @@ private static (MarkupSyntaxNode? Start, MarkupSyntaxNode? End) GetStartAndEndEl
286
286
}
287
287
288
288
/// <summary>
289
- /// Processes a multi-point selection, providing the start and end of the extraction range if successful.
289
+ /// Processes a selection, providing the start and end of the extraction range if successful.
290
290
/// </summary>
291
291
/// <param name="startElementNode">The starting element of the selection.</param>
292
- /// <param name="endElementNode">The ending element of the selection, if it exists. </param>
292
+ /// <param name="endElementNode">The ending element of the selection</param>
293
293
/// <param name="codeDocument">The code document containing the selection.</param>
294
- /// <param name="actionParams">The parameters for the extraction action, which will be updated. </param>
294
+ /// <param name="actionParams">The parameters for the extraction action</param>
295
295
/// <param name="extractStart">The start of the extraction range.</param>
296
296
/// <param name="extractEnd">The end of the extraction range</param>
297
297
/// <returns> <c>true</c> if the selection was successfully processed; otherwise, <c>false</c>.</returns>
298
- private static bool TryProcessMultiPointSelection ( MarkupSyntaxNode startElementNode , MarkupSyntaxNode endElementNode , RazorCodeDocument codeDocument , ExtractToComponentCodeActionParams actionParams , out int extractStart , out int extractEnd )
298
+ private static bool TryProcessSelection ( MarkupSyntaxNode startElementNode , MarkupSyntaxNode endElementNode , RazorCodeDocument codeDocument , ExtractToComponentCodeActionParams actionParams , out int extractStart , out int extractEnd )
299
299
{
300
300
extractStart = startElementNode . Span . Start ;
301
301
extractEnd = endElementNode . Span . End ;
@@ -388,10 +388,14 @@ private static (SyntaxNode? Start, SyntaxNode? End) FindContainingSiblingPair(Sy
388
388
389
389
var endIsCodeBlock = endNode is CSharpCodeBlockSyntax ;
390
390
391
- foreach ( var child in nearestCommonAncestor . ChildNodes ( ) . Where ( node => IsValidNode ( node , endIsCodeBlock ) ) )
391
+ foreach ( var child in nearestCommonAncestor . ChildNodes ( ) )
392
392
{
393
- var childSpan = child . Span ;
393
+ if ( ! IsValidNode ( child , endIsCodeBlock ) )
394
+ {
395
+ continue ;
396
+ }
394
397
398
+ var childSpan = child . Span ;
395
399
if ( startContainingNode is null && childSpan . Contains ( startSpan ) )
396
400
{
397
401
startContainingNode = child ;
0 commit comments