@@ -478,28 +478,28 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
478478
479479 // GH#11556 - make sure to format the error code to this string as an UNSIGNED int
480480 const auto failureText = RS_fmt (L" ProcessFailedToLaunch" , _formatStatus (hr), _commandline);
481- TerminalOutput. raise (failureText);
481+ _dhSend16 (failureText);
482482
483483 // If the path was invalid, let's present an informative message to the user
484484 if (hr == HRESULT_FROM_WIN32 (ERROR_DIRECTORY))
485485 {
486486 const auto badPathText = RS_fmt (L" BadPathText" , _startingDirectory);
487- TerminalOutput. raise (L" \r\n " );
488- TerminalOutput. raise (badPathText);
487+ _dhSend16 (L" \r\n " );
488+ _dhSend16 (badPathText);
489489 }
490490 // If the requested action requires elevation, display appropriate message
491491 else if (hr == HRESULT_FROM_WIN32 (ERROR_ELEVATION_REQUIRED))
492492 {
493493 const auto elevationText = RS_ (L" ElevationRequired" );
494- TerminalOutput. raise (L" \r\n " );
495- TerminalOutput. raise (elevationText);
494+ _dhSend16 (L" \r\n " );
495+ _dhSend16 (elevationText);
496496 }
497497 // If the requested executable was not found, display appropriate message
498498 else if (hr == HRESULT_FROM_WIN32 (ERROR_FILE_NOT_FOUND))
499499 {
500500 const auto fileNotFoundText = RS_ (L" FileNotFound" );
501- TerminalOutput. raise (L" \r\n " );
502- TerminalOutput. raise (fileNotFoundText);
501+ _dhSend16 (L" \r\n " );
502+ _dhSend16 (fileNotFoundText);
503503 }
504504
505505 _transitionToState (ConnectionState::Failed);
@@ -520,7 +520,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
520520 const auto msg1 = RS_fmt (L" ProcessExited" , _formatStatus (status));
521521 const auto msg2 = RS_ (L" CtrlDToClose" );
522522 const auto msg = fmt::format (FMT_COMPILE (L" \r\n {}\r\n {}\r\n " ), msg1, msg2);
523- TerminalOutput. raise (msg);
523+ _dhSend16 (msg);
524524 }
525525 CATCH_LOG ();
526526 }
@@ -745,11 +745,12 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
745745 const wil::unique_event overlappedEvent{ CreateEventExW (nullptr , nullptr , CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS) };
746746 OVERLAPPED overlapped{ .hEvent = overlappedEvent.get () };
747747 bool overlappedPending = false ;
748- char buffer[128 * 1024 ];
749- DWORD read = 0 ;
750748
751- til::u8state u8State;
752- std::wstring wstr;
749+ char buffer[128 * 1024 ], buffer2[128 *1024 ];
750+ char * thisBuffer = buffer;
751+ DWORD read = 0 ;
752+ char * lastBuffer = buffer2;
753+ DWORD lastRead = 0 ;
753754
754755 // If we use overlapped IO We want to queue ReadFile() calls before processing the
755756 // string, because TerminalOutput.raise() may take a while (relatively speaking).
@@ -760,7 +761,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
760761 // When we have a `wstr` that's ready for processing we must do so without blocking.
761762 // Otherwise, whatever the user typed will be delayed until the next IO operation.
762763 // With overlapped IO that's not a problem because the ReadFile() calls won't block.
763- if (!ReadFile (_pipe.get (), &buffer[ 0 ] , sizeof (buffer), &read, &overlapped))
764+ if (!ReadFile (_pipe.get (), thisBuffer , sizeof (buffer), &read, &overlapped))
764765 {
765766 if (GetLastError () != ERROR_IO_PENDING)
766767 {
@@ -772,7 +773,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
772773 // wstr can be empty in two situations:
773774 // * The previous call to til::u8u16 failed.
774775 // * We're using overlapped IO, and it's the first iteration.
775- if (!wstr. empty () )
776+ if (lastBuffer && lastRead )
776777 {
777778 if (!_receivedFirstByte)
778779 {
@@ -792,7 +793,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
792793
793794 try
794795 {
795- TerminalOutput.raise (wstr );
796+ TerminalOutput.raise (winrt::array_view{ reinterpret_cast < const uint8_t *>(lastBuffer), lastRead } );
796797 }
797798 CATCH_LOG ();
798799 }
@@ -832,8 +833,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
832833 TraceLoggingLevel (WINEVENT_LEVEL_VERBOSE),
833834 TraceLoggingKeyword (TIL_KEYWORD_TRACE));
834835
835- // If we hit a parsing error, eat it. It's bad utf-8, we can't do anything with it.
836- FAILED_LOG (til::u8u16 ({ &buffer[0 ], gsl::narrow_cast<size_t >(read) }, wstr, u8State));
836+ std::swap (thisBuffer, lastBuffer);
837837 }
838838
839839 return 0 ;
0 commit comments