Repository: microsoft/terminal (language: cpp)

Issue:
`more` command doesn't advance to the next screen of text if I press spacebar 
### Windows Terminal version

1.18.902.0

### Windows build number

10.0.23432.1000

### Other Software

I tested this in cmd and PowerShell (version info below):

```
Name              : Microsoft.PowerShell
Publisher         : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
Architecture      : X64
ResourceId        :
Version           : 7.3.3.0
```



### Steps to reproduce

1. Within cmd.exe or pwsh.exe, and with a file that has at least a 'screenful' of text (e.g., call it `foo.txt`), try using `more foo.txt` to view the file's contents, one screenful at a time.
2. After the first screenful is displayed, try pressing spacebar to advance to the next chunk. 

### Expected Behavior

The Terminal advances to the next page of text.

### Actual Behavior

The Terminal remains at the current screen; I see the cursor flashing as normal. I also can't Ctrl+C out of this. 

I don't see this behavior in retail Terminal (version 1.16.10262.0)- `more` behaves as I would expect there.


Discussion / hints:
Aahhhh. This could be an OpenConsole crash? Can you check to see whether there's still an OpenConsole instance running for that terminal tab?

(The renderer is still working, evidenced by the cursor flashing.)

/cc @lhecker for potential buffer impact
Thanks for taking a look! OpenConsole is still running per Task Manager. 
I am hitting this issue as well, 100% consistent repro (on 1.18.902.0.) 

Pressing ctrl+break gets me 'unstuck' but all other key presses seem to be ignored.
I wonder if this is from the linefeed changes in #14874 
This also happens in OpenConsole...!
Broken in a build made on 2023 day 81.
Works on 2023 33.
Broken on 2023 62.
This regressed in #14745 (`TranslateUnicodeToOem`)

I bet it's reading input with `ReadConsoleInputA`! 😉

/cc @lhecker

Fix patch:
diff --git a/src/host/stream.cpp b/src/host/stream.cpp
index 5ab812bda9a..9ecccd2fadb 100644
--- a/src/host/stream.cpp
+++ b/src/host/stream.cpp
@@ -436,16 +436,16 @@ try
 
     inputBuffer.ConsumeCached(unicode, writer);
 
-    // We don't need to wait for input if `ConsumeCached` read something already, which is
-    // indicated by the writer having been advanced (= it's shorter than the original buffer).
-    auto wait = writer.size() == buffer.size();
+    auto noDataReadYet = writer.size() == buffer.size();
     auto status = STATUS_SUCCESS;
 
     while (writer.size() >= charSize)
     {
         wchar_t wch;
-        status = GetChar(&inputBuffer, &wch, wait, nullptr, nullptr, nullptr);
-        if (!NT_SUCCESS(status))
+        // We don't need to wait for input if `ConsumeCached` read something already, which is
+        // indicated by the writer having been advanced (= it's shorter than the original buffer).
+        status = GetChar(&inputBuffer, &wch, noDataReadYet, nullptr, nullptr, nullptr);
+        if (FAILED_NTSTATUS(status))
         {
             break;
         }
@@ -453,11 +453,13 @@ try
         std::wstring_view wchView{ &wch, 1 };
         inputBuffer.Consume(unicode, wchView, writer);
 
-        wait = false;
+        noDataReadYet = false;
     }
 
     bytesRead = buffer.size() - writer.size();
-    return status;
+    // Once we read some data off the InputBuffer it can't be read again, so we
+    // need to make sure to return a success status to the client in that case.
+    return noDataReadYet ? status : STATUS_SUCCESS;
 }
 NT_CATCH_RETURN()
 


Test patch: