@@ -1104,40 +1104,39 @@ void M()
11041104
11051105 Assert . True ( result ) ;
11061106
1107- // Verify all caret positions are set correctly
1108- var selections = view . Selection . SelectedSpans ;
1109- Assert . Equal ( 2 , selections . Count ) ;
1110-
1111- // The expected output should have carets at these positions
1112- var expectedOutput = """
1107+ // Verify the expected markup with all caret positions
1108+ var expectedMarkup = """
11131109 class C
11141110 {
11151111 void M()
11161112 {
11171113 var v = "now is " +
1118- "the ti" +
1119- "me";
1114+ "[||] the ti" +
1115+ "[||] me";
11201116 }
11211117 }
11221118 """ ;
11231119
1120+ MarkupTestFile . GetSpans ( expectedMarkup , out var expectedOutput , out var expectedSpans ) ;
11241121 var actualText = textBuffer . CurrentSnapshot . AsText ( ) . ToString ( ) ;
1125- Assert . Equal ( expectedOutput , actualText ) ;
11261122
1127- // Find the expected caret positions in the output
1128- var firstCaretPosition = actualText . IndexOf ( "\" the ti\" " ) ;
1129- var secondCaretPosition = actualText . IndexOf ( "\" me\" " ) ;
1123+ // Verify text is correct
1124+ Assert . Equal ( expectedOutput , actualText ) ;
11301125
1131- Assert . True ( firstCaretPosition > 0 ) ;
1132- Assert . True ( secondCaretPosition > 0 ) ;
1126+ // Verify all caret positions are set correctly
1127+ var broker = view . GetMultiSelectionBroker ( ) ;
1128+ var selections = broker . AllSelections . ToList ( ) ;
1129+ Assert . Equal ( expectedSpans . Length , selections . Count ) ;
11331130
1134- // Verify selections are at the start of the continuation strings
1135- var firstSelection = selections [ 0 ] ;
1136- var secondSelection = selections [ 1 ] ;
1131+ // Verify each selection position matches the expected position
1132+ for ( int i = 0 ; i < expectedSpans . Length ; i ++ )
1133+ {
1134+ Assert . Equal ( expectedSpans [ i ] . Start , selections [ i ] . Start . Position . Position ) ;
1135+ Assert . True ( selections [ i ] . IsEmpty ) ; // All selections should be carets (zero-length)
1136+ }
11371137
1138- // The carets should be right after the opening quotes of the continuation strings
1139- Assert . True ( firstSelection . Start . Position >= firstCaretPosition && firstSelection . Start . Position <= firstCaretPosition + 10 ) ;
1140- Assert . True ( secondSelection . Start . Position >= secondCaretPosition && secondSelection . Start . Position <= secondCaretPosition + 10 ) ;
1138+ // Verify the primary (last) caret is at the correct position
1139+ Assert . Equal ( expectedSpans . Last ( ) . Start , view . Caret . Position . BufferPosition . Position ) ;
11411140 }
11421141
11431142 [ WpfFact , WorkItem ( "https://github.com/dotnet/roslyn/issues/40277" ) ]
0 commit comments