mirror of
https://github.com/microsoft/terminal.git
synced 2026-07-08 17:46:05 +00:00
Fix a deadlock during cooked reads (#19994)
Closes #19922 ## Validation Steps Performed * The repro now works as expected ✅ (`CreatePseudoConsole({1,20})` + `WriteFile("キ")`)
This commit is contained in:
@@ -1313,6 +1313,15 @@ COOKED_READ_DATA::LayoutResult COOKED_READ_DATA::_layoutLine(std::wstring& outpu
|
||||
til::CoordType cols = 0;
|
||||
const auto len = textBuffer.FitTextIntoColumns(text, columnLimit - column, cols);
|
||||
|
||||
// GH#19922: We need to account for terminals that are just 1 column wide, as we may deadlock otherwise.
|
||||
// `columnLimit - column == 1` will then prevent `FitTextIntoColumns` from fitting any wide glyphs.
|
||||
// We can detect this by checking for `len == 0`, skip the offending glyph and break out of the deadlock.
|
||||
if (len == 0) [[unlikely]]
|
||||
{
|
||||
it += textBuffer.GraphemeNext(text, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
output.append(text, 0, len);
|
||||
column += cols;
|
||||
it += len;
|
||||
|
||||
Reference in New Issue
Block a user