-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly implement WaitForData for ReadConsoleInput (#18228)
There were two bugs: * Ever since the conhost v1 -> v2 rewrite the `readDataDirect.cpp` implementation incorrectly passed `false` as the wait flag. The unintentional mistake is obvious in hindsight as the check for `CONSOLE_STATUS_WAIT` makes no sense in this case. * The ConPTY integration into `InputBuffer` was done incorrectly, as it would unconditionally wake up the readers/waiters without checking if the buffer is now actually non-empty. Closes #15859 ## Validation Steps Performed Test code: ```cpp #include <Windows.h> #include <stdio.h> int main() { HANDLE in = GetStdHandle(STD_INPUT_HANDLE); INPUT_RECORD buf[128]; DWORD read; SetConsoleMode( in, ENABLE_PROCESSED_INPUT | ENABLE_VIRTUAL_TERMINAL_INPUT ); for (int i = 0; ReadConsoleInputW(in, buf, 128, &read); ++i) { printf("%d read=%lu\n", i, read); } return 0; } ``` Run it under Windows Terminal and type any input. >50% of all inputs will result in `read=0`. This is fixed after this PR.
- Loading branch information
Showing
8 changed files
with
51 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters