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)