terminal/src/host/ut_host
James Holderness 974e95ebf7 Make the RIS command clear the display and scrollback correctly (#2367)
When the scrollback buffer is empty, the RIS escape sequence (Reset to Initial
State) will fail to clear the screen, or reset any of the state. And when there
is something in the scrollback, it doesn't get cleared completely, and the
screen may get filled with the wrong background color (it should use the
default color, but it actually uses the previously active background color).
This commit attempts to fix those issues.

The initial failure is caused by the `SCREEN_INFORMATION::WriteRect` method
throwing an exception when passed an empty viewport. And the reason it's passed
an empty viewport is because that's what the `Viewport::Subtract` method
returns when the result of the subtraction is nothing.  The PR fixes the
problem by making the `Viewport::Subtract` method actually return nothing in
that situation. 

This is a change in the defined behavior that also required the associated
viewport tests to be updated. However, it does seem a sensible change, since
the `Subtract` method never returns empty viewports under any other
circumstances. And the only place the method seems to be used is in the
`ScrollRegion` implementation, where the previous behavior is guaranteed to
throw an exception.

The other issues are fixed simply by changing the order in which things are
reset in the `AdaptDispatch::HardReset` method. The call to `SoftReset` needed
to be made first, so that the SGR attributes would be reset before the screen
was cleared, thus making sure that the default background color would be used.
And the screen needed to be cleared before the scrollback was erased, otherwise
the last view of the screen would be retained in the scrollback buffer.

These changes also required existing adapter tests to be updated, but not
because of a change in the expected behaviour. It's just that certain tests
relied on the `SoftReset` happening later in the order, so weren't expecting it
to be called if say the scrollback erase had failed. It doesn't seem like the
tests were deliberately trying to verify that the SoftReset _hadn't_ been
called.

In addition to the updates to existing tests, this PR also add a new screen
buffer test which verifies the display and scrollback are correctly cleared
under the conditions that were previously failing.

Fixes #2307.
2019-08-27 18:45:38 -07:00
..
AliasTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ApiRoutinesTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
AttrRowTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CharRowBaseTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ClipboardTests.cpp Set utf-8 for the entire project (#1929) 2019-07-11 13:13:10 -07:00
CodepointWidthDetectorTests.cpp Replace CodepointWidthDetector's runtime table with a static one (#2368) 2019-08-16 10:54:17 -07:00
CommandLineTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CommandListPopupTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CommandNumberPopupTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ConsoleArgumentsTests.cpp Fix the conhost command line not being properly escaped (#1815) 2019-07-11 19:38:56 -07:00
CopyFromCharPopupTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CopyToCharPopupTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
DbcsTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
DefaultResource.rc Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
HistoryTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
Host.UnitTests.vcxproj Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
Host.UnitTests.vcxproj.filters Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
InitTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
InputBufferTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
OutputCellIteratorTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
PopupTestHelper.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
product.pbxproj Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
ReadWaitTests.cpp Removed using namespace directive from header files (#955) 2019-05-30 11:14:21 -07:00
RendererTests.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
ScreenBufferTests.cpp Make the RIS command clear the display and scrollback correctly (#2367) 2019-08-27 18:45:38 -07:00
SearchTests.cpp Removed using namespace directive from header files (#955) 2019-05-30 11:14:21 -07:00
SelectionTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
sources Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
sources.dep Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
testmd.definition inbox: reflect incoming changes up to uxp aa5182a2 (#1916) 2019-07-10 12:40:51 -07:00
TextBufferIteratorTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
TextBufferTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
TitleTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
Utf8ToWideCharParserTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
Utf16ParserTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
UtilsTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ViewportTests.cpp Make the RIS command clear the display and scrollback correctly (#2367) 2019-08-27 18:45:38 -07:00
VtIoTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
VtRendererTests.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00