From f60566c46a4987b11a06ee337311c48bcc59269a Mon Sep 17 00:00:00 2001 From: Michael Niksa Date: Thu, 26 Sep 2019 15:46:15 -0700 Subject: [PATCH] Patch fix for #1360 until WriteStream (#780) can be implemented. --- src/cascadia/TerminalCore/Terminal.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/cascadia/TerminalCore/Terminal.cpp b/src/cascadia/TerminalCore/Terminal.cpp index 9bf2da143f2..50dcae2e643 100644 --- a/src/cascadia/TerminalCore/Terminal.cpp +++ b/src/cascadia/TerminalCore/Terminal.cpp @@ -381,6 +381,18 @@ void Terminal::_WriteBuffer(const std::wstring_view& stringView) } } + // If we're about to try to place the cursor past the right edge of the buffer, move it down a row + // This is another patch that GH#780 should supercede. This is really correcting for other bad situations + // like bisecting (writing only the leading half because there's no room for the trailing) a wide character + // into the buffer. However, it's not really all-up correctable without implementing a full WriteStream here. + // Also, this particular code RIGHT HERE shouldn't need to know anything about the cursor or the cells advanced + // which also will be solved by GH#780 (hopefully). + if (proposedCursorPosition.X > bufferSize.RightInclusive()) + { + proposedCursorPosition.X = 0; + proposedCursorPosition.Y++; + } + // If we're about to scroll past the bottom of the buffer, instead cycle the buffer. const auto newRows = proposedCursorPosition.Y - bufferSize.Height() + 1; if (newRows > 0)