[flutter_tools] catch StdinException when setting terminal to SingleCharMode (#136283)

Fixes https://github.com/flutter/flutter/issues/129198
This commit is contained in:
Christopher Fujino
2023-10-10 17:10:29 -06:00
committed by GitHub
parent 54cf286e1a
commit b416473bbb
3 changed files with 60 additions and 9 deletions

View File

@@ -314,13 +314,19 @@ class AnsiTerminal implements Terminal {
return;
}
final io.Stdin stdin = _stdio.stdin as io.Stdin;
// The order of setting lineMode and echoMode is important on Windows.
if (value) {
stdin.echoMode = false;
stdin.lineMode = false;
} else {
stdin.lineMode = true;
stdin.echoMode = true;
try {
// The order of setting lineMode and echoMode is important on Windows.
if (value) {
stdin.echoMode = false;
stdin.lineMode = false;
} else {
stdin.lineMode = true;
stdin.echoMode = true;
}
} on io.StdinException {
// If the pipe to STDIN has been closed it's probably because the
// terminal has been closed, and there is nothing actionable to do here.
}
}