Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move cursor to left margin for IL and DL controls #2731

Merged
merged 2 commits into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/host/getset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2021,6 +2021,7 @@ void DoSrvPrivateSetDefaultTabStops()

// Routine Description:
// - internal logic for adding or removing lines in the active screen buffer
// this also moves the cursor to the left margin, which is expected behaviour for IL and DL
// Parameters:
// - count - the number of lines to modify
// - insert - true if inserting lines, false if deleting lines
Expand Down Expand Up @@ -2069,6 +2070,10 @@ void DoSrvPrivateModifyLinesImpl(const unsigned int count, const bool insert)
screenInfo.GetAttributes());
}
CATCH_LOG();

// The IL and DL controls are also expected to move the cursor to the left margin.
// For now this is just column 0, since we don't yet support DECSLRM.
LOG_IF_NTSTATUS_FAILED(screenInfo.SetCursorPosition({ 0, cursorPosition.Y }, false));
}
}

Expand Down
24 changes: 18 additions & 6 deletions src/host/ut_host/ScreenBufferTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3230,8 +3230,16 @@ void ScreenBufferTests::ScrollOperations()
VERIFY_SUCCEEDED(si.SetCursorPosition(cursorPos, true));
stateMachine.ProcessString(escapeSequence.str());

Log::Comment(L"Verify cursor didn't move.");
VERIFY_ARE_EQUAL(cursorPos, cursor.GetPosition());
// The cursor shouldn't move.
auto expectedCursorPos = cursorPos;
// Unless this is an IL or DL control, which moves the cursor to the left margin.
if (scrollType == InsertLine || scrollType == DeleteLine)
{
expectedCursorPos.X = 0;
}

Log::Comment(L"Verify expected cursor position.");
VERIFY_ARE_EQUAL(expectedCursorPos, cursor.GetPosition());

Log::Comment(L"Field of Zs outside viewport should remain unchanged.");
VERIFY_IS_TRUE(_ValidateLinesContain(0, viewportStart, bufferChar, bufferAttr));
Expand Down Expand Up @@ -3749,7 +3757,8 @@ void ScreenBufferTests::InsertLinesInMargins()
Log::Comment(NoThrowString().Format(
L"viewport=%s", VerifyOutputTraits<SMALL_RECT>::ToString(si.GetViewport().ToInclusive()).GetBuffer()));

VERIFY_ARE_EQUAL(4, cursor.GetPosition().X);
// Verify cursor moved to left margin.
VERIFY_ARE_EQUAL(0, cursor.GetPosition().X);
VERIFY_ARE_EQUAL(2, cursor.GetPosition().Y);
{
auto iter0 = tbi.GetCellDataAt({ 0, 0 });
Expand Down Expand Up @@ -3783,7 +3792,8 @@ void ScreenBufferTests::InsertLinesInMargins()
Log::Comment(NoThrowString().Format(
L"viewport=%s", VerifyOutputTraits<SMALL_RECT>::ToString(si.GetViewport().ToInclusive()).GetBuffer()));

VERIFY_ARE_EQUAL(4, cursor.GetPosition().X);
// Verify cursor moved to left margin.
VERIFY_ARE_EQUAL(0, cursor.GetPosition().X);
VERIFY_ARE_EQUAL(1, cursor.GetPosition().Y);
{
auto iter0 = tbi.GetCellDataAt({ 0, 0 });
Expand Down Expand Up @@ -3824,7 +3834,8 @@ void ScreenBufferTests::DeleteLinesInMargins()
Log::Comment(NoThrowString().Format(
L"viewport=%s", VerifyOutputTraits<SMALL_RECT>::ToString(si.GetViewport().ToInclusive()).GetBuffer()));

VERIFY_ARE_EQUAL(4, cursor.GetPosition().X);
// Verify cursor moved to left margin.
VERIFY_ARE_EQUAL(0, cursor.GetPosition().X);
VERIFY_ARE_EQUAL(2, cursor.GetPosition().Y);
{
auto iter0 = tbi.GetCellDataAt({ 0, 0 });
Expand Down Expand Up @@ -3858,7 +3869,8 @@ void ScreenBufferTests::DeleteLinesInMargins()
Log::Comment(NoThrowString().Format(
L"viewport=%s", VerifyOutputTraits<SMALL_RECT>::ToString(si.GetViewport().ToInclusive()).GetBuffer()));

VERIFY_ARE_EQUAL(4, cursor.GetPosition().X);
// Verify cursor moved to left margin.
VERIFY_ARE_EQUAL(0, cursor.GetPosition().X);
VERIFY_ARE_EQUAL(1, cursor.GetPosition().Y);
{
auto iter0 = tbi.GetCellDataAt({ 0, 0 });
Expand Down