Skip to content

Commit

Permalink
Make sure the "delay EOL wrap" behaviour is only applied when the ENA…
Browse files Browse the repository at this point in the history
…BLE_WRAP_AT_EOL_OUTPUT mode is set.
  • Loading branch information
j4james committed Dec 21, 2019
1 parent 6f667f4 commit 7dbefe0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/host/_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ constexpr unsigned int LOCAL_BUFFER_SIZE = 100;
WCHAR LocalBuffer[LOCAL_BUFFER_SIZE];
size_t TempNumSpaces = 0;
const bool fUnprocessed = WI_IsFlagClear(screenInfo.OutputMode, ENABLE_PROCESSED_OUTPUT);
const bool fWrapAtEOL = WI_IsFlagSet(screenInfo.OutputMode, ENABLE_WRAP_AT_EOL_OUTPUT);

// Must not adjust cursor here. It has to stay on for many write scenarios. Consumers should call for the
// cursor to be turned off if they want that.
Expand All @@ -323,7 +324,7 @@ constexpr unsigned int LOCAL_BUFFER_SIZE = 100;
while (*pcb < BufferSize)
{
// correct for delayed EOL
if (cursor.IsDelayedEOLWrap())
if (cursor.IsDelayedEOLWrap() && fWrapAtEOL)
{
const COORD coordDelayedAt = cursor.GetDelayedAtPosition();
cursor.ResetDelayEOLWrap();
Expand Down Expand Up @@ -561,7 +562,7 @@ constexpr unsigned int LOCAL_BUFFER_SIZE = 100;
CursorPosition.X = XPosition;

// enforce a delayed newline if we're about to pass the end and the WC_DELAY_EOL_WRAP flag is set.
if (WI_IsFlagSet(dwFlags, WC_DELAY_EOL_WRAP) && CursorPosition.X >= coordScreenBufferSize.X)
if (WI_IsFlagSet(dwFlags, WC_DELAY_EOL_WRAP) && CursorPosition.X >= coordScreenBufferSize.X && fWrapAtEOL)
{
// Our cursor position as of this time is going to remain on the last position in this column.
CursorPosition.X = coordScreenBufferSize.X - 1;
Expand Down Expand Up @@ -730,7 +731,7 @@ constexpr unsigned int LOCAL_BUFFER_SIZE = 100;
}
CATCH_LOG();
}
if (cursor.GetPosition().X == 0 && (screenInfo.OutputMode & ENABLE_WRAP_AT_EOL_OUTPUT) && pwchBuffer > pwchBufferBackupLimit)
if (cursor.GetPosition().X == 0 && fWrapAtEOL && pwchBuffer > pwchBufferBackupLimit)
{
if (CheckBisectProcessW(screenInfo,
pwchBufferBackupLimit,
Expand Down Expand Up @@ -842,7 +843,7 @@ constexpr unsigned int LOCAL_BUFFER_SIZE = 100;
if (Char >= UNICODE_SPACE &&
IsGlyphFullWidth(Char) &&
XPosition >= (coordScreenBufferSize.X - 1) &&
(screenInfo.OutputMode & ENABLE_WRAP_AT_EOL_OUTPUT))
fWrapAtEOL)
{
const COORD TargetPoint = cursor.GetPosition();
ROW& Row = textBuffer.GetRowByOffset(TargetPoint.Y);
Expand Down

0 comments on commit 7dbefe0

Please sign in to comment.