mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-10 18:43:54 -06:00
Fix CRLF translation when DISABLE_NEWLINE_AUTO_RETURN is reset (#18781)
We can't do the `pos.x != 0` check. Instead, I replaced it with a CR check to avoid redundant CRs during CRLF translation. Closes #18735 ## Validation Steps Performed * Run the repro in the linked issue
This commit is contained in:
parent
8b01f546cb
commit
354e05d713
@ -269,17 +269,26 @@ void WriteCharsLegacy(SCREEN_INFORMATION& screenInfo, const std::wstring_view& t
|
|||||||
case UNICODE_LINEFEED:
|
case UNICODE_LINEFEED:
|
||||||
{
|
{
|
||||||
auto pos = cursor.GetPosition();
|
auto pos = cursor.GetPosition();
|
||||||
if (WI_IsFlagClear(screenInfo.OutputMode, DISABLE_NEWLINE_AUTO_RETURN) && pos.x != 0)
|
|
||||||
|
// If DISABLE_NEWLINE_AUTO_RETURN is not set, any LF behaves like a CRLF.
|
||||||
|
if (WI_IsFlagClear(screenInfo.OutputMode, DISABLE_NEWLINE_AUTO_RETURN))
|
||||||
{
|
{
|
||||||
pos.x = 0;
|
pos.x = 0;
|
||||||
// This causes the current \n to be replaced with a \r\n in the ConPTY VT output.
|
|
||||||
wch = 0;
|
// Setting wch=0 and lastCharWrapped=true will cause the code at the end
|
||||||
lastCharWrapped = true;
|
// of the loop to emit a CRLF. However, we only do this if the preceding
|
||||||
|
// character isn't already a CR. We don't want to emit CR CR LF after all.
|
||||||
|
if (it == beg || it[-1] != '\r')
|
||||||
|
{
|
||||||
|
wch = 0;
|
||||||
|
lastCharWrapped = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
textBuffer.GetMutableRowByOffset(pos.y).SetWrapForced(false);
|
textBuffer.GetMutableRowByOffset(pos.y).SetWrapForced(false);
|
||||||
pos.y = pos.y + 1;
|
pos.y = pos.y + 1;
|
||||||
AdjustCursorPosition(screenInfo, pos, psScrollY);
|
AdjustCursorPosition(screenInfo, pos, psScrollY);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case UNICODE_CARRIAGERETURN:
|
case UNICODE_CARRIAGERETURN:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user