Skip to content

Commit 86c3219

Browse files
console : fix issue related to Windows 11 PowerShell console mode persistence (#2521)
1 parent 2e8265a commit 86c3219

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

examples/console.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ namespace console {
8080
// Set console input codepage to UTF16
8181
_setmode(_fileno(stdin), _O_WTEXT);
8282

83-
if (!simple_io) {
84-
// Turn off ICANON (ENABLE_LINE_INPUT) and ECHO (ENABLE_ECHO_INPUT)
83+
// Set ICANON (ENABLE_LINE_INPUT) and ECHO (ENABLE_ECHO_INPUT)
84+
if (simple_io) {
85+
dwMode |= ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT;
86+
} else {
8587
dwMode &= ~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT);
8688
}
8789
if (!SetConsoleMode(hConIn, dwMode)) {

0 commit comments

Comments
 (0)