mirror of
https://github.com/microsoft/terminal.git
synced 2026-02-13 13:45:27 +00:00
Return success if ReadCharacterInput read >0 characters (#15122)
This is a regression caused by599b550. If I'm reading `stream.cpp` incf87590right, it returns `STATUS_SUCCESS` if `ReadCharacterInput` read at least 1 character. I think? this PR makes the code behave exactly equivalent. The old code is a bit of an "acquired taste" so it's a bit hard to tell. Closes #15116 ## PR Checklist * Run `more long_text_file.txt` in cmd * Press Spacebar * Scrolls down ✅ * Press Q * Exits ✅
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user