@@ -3230,8 +3230,16 @@ void ScreenBufferTests::ScrollOperations()
32303230 VERIFY_SUCCEEDED (si.SetCursorPosition (cursorPos, true ));
32313231 stateMachine.ProcessString (escapeSequence.str ());
32323232
3233- Log::Comment (L" Verify cursor didn't move." );
3234- VERIFY_ARE_EQUAL (cursorPos, cursor.GetPosition ());
3233+ // The cursor shouldn't move.
3234+ auto expectedCursorPos = cursorPos;
3235+ // Unless this is an IL or DL control, which moves the cursor to the left margin.
3236+ if (scrollType == InsertLine || scrollType == DeleteLine)
3237+ {
3238+ expectedCursorPos.X = 0 ;
3239+ }
3240+
3241+ Log::Comment (L" Verify expected cursor position." );
3242+ VERIFY_ARE_EQUAL (expectedCursorPos, cursor.GetPosition ());
32353243
32363244 Log::Comment (L" Field of Zs outside viewport should remain unchanged." );
32373245 VERIFY_IS_TRUE (_ValidateLinesContain (0 , viewportStart, bufferChar, bufferAttr));
@@ -3749,7 +3757,8 @@ void ScreenBufferTests::InsertLinesInMargins()
37493757 Log::Comment (NoThrowString ().Format (
37503758 L" viewport=%s" , VerifyOutputTraits<SMALL_RECT >::ToString (si.GetViewport ().ToInclusive ()).GetBuffer ()));
37513759
3752- VERIFY_ARE_EQUAL (4 , cursor.GetPosition ().X );
3760+ // Verify cursor moved to left margin.
3761+ VERIFY_ARE_EQUAL (0 , cursor.GetPosition ().X );
37533762 VERIFY_ARE_EQUAL (2 , cursor.GetPosition ().Y );
37543763 {
37553764 auto iter0 = tbi.GetCellDataAt ({ 0 , 0 });
@@ -3783,7 +3792,8 @@ void ScreenBufferTests::InsertLinesInMargins()
37833792 Log::Comment (NoThrowString ().Format (
37843793 L" viewport=%s" , VerifyOutputTraits<SMALL_RECT >::ToString (si.GetViewport ().ToInclusive ()).GetBuffer ()));
37853794
3786- VERIFY_ARE_EQUAL (4 , cursor.GetPosition ().X );
3795+ // Verify cursor moved to left margin.
3796+ VERIFY_ARE_EQUAL (0 , cursor.GetPosition ().X );
37873797 VERIFY_ARE_EQUAL (1 , cursor.GetPosition ().Y );
37883798 {
37893799 auto iter0 = tbi.GetCellDataAt ({ 0 , 0 });
@@ -3824,7 +3834,8 @@ void ScreenBufferTests::DeleteLinesInMargins()
38243834 Log::Comment (NoThrowString ().Format (
38253835 L" viewport=%s" , VerifyOutputTraits<SMALL_RECT >::ToString (si.GetViewport ().ToInclusive ()).GetBuffer ()));
38263836
3827- VERIFY_ARE_EQUAL (4 , cursor.GetPosition ().X );
3837+ // Verify cursor moved to left margin.
3838+ VERIFY_ARE_EQUAL (0 , cursor.GetPosition ().X );
38283839 VERIFY_ARE_EQUAL (2 , cursor.GetPosition ().Y );
38293840 {
38303841 auto iter0 = tbi.GetCellDataAt ({ 0 , 0 });
@@ -3858,7 +3869,8 @@ void ScreenBufferTests::DeleteLinesInMargins()
38583869 Log::Comment (NoThrowString ().Format (
38593870 L" viewport=%s" , VerifyOutputTraits<SMALL_RECT >::ToString (si.GetViewport ().ToInclusive ()).GetBuffer ()));
38603871
3861- VERIFY_ARE_EQUAL (4 , cursor.GetPosition ().X );
3872+ // Verify cursor moved to left margin.
3873+ VERIFY_ARE_EQUAL (0 , cursor.GetPosition ().X );
38623874 VERIFY_ARE_EQUAL (1 , cursor.GetPosition ().Y );
38633875 {
38643876 auto iter0 = tbi.GetCellDataAt ({ 0 , 0 });
0 commit comments