From ec24517a97a473ada508c47566fcf1f47257da2b Mon Sep 17 00:00:00 2001 From: James Holderness Date: Sat, 27 Apr 2024 18:38:32 +0100 Subject: [PATCH] Fix DECTCEM reset position in conpty stream. --- src/renderer/vt/XtermEngine.cpp | 3 ++- src/renderer/vt/state.cpp | 1 + src/renderer/vt/vtrenderer.hpp | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/renderer/vt/XtermEngine.cpp b/src/renderer/vt/XtermEngine.cpp index 14822351585..75fc3510fa6 100644 --- a/src/renderer/vt/XtermEngine.cpp +++ b/src/renderer/vt/XtermEngine.cpp @@ -45,6 +45,7 @@ XtermEngine::XtermEngine(_In_ wil::unique_hfile hPipe, // visible, then PaintCursor will be called, and we'll set this to true // during the frame. _nextCursorIsVisible = false; + _startOfFrameBufferIndex = _buffer.size(); // Do not perform synchronization clearing in passthrough mode. // In passthrough, the terminal leads and we follow what it is @@ -112,7 +113,7 @@ XtermEngine::XtermEngine(_In_ wil::unique_hfile hPipe, // by prepending a cursor off. if (_lastCursorIsVisible != Tribool::False) { - _buffer.insert(0, "\x1b[?25l"); + _buffer.insert(_startOfFrameBufferIndex, "\x1b[?25l"); _lastCursorIsVisible = Tribool::False; } // If the cursor was NOT previously visible, then that's fine! we don't diff --git a/src/renderer/vt/state.cpp b/src/renderer/vt/state.cpp index ea176e42f37..881fb0c2cce 100644 --- a/src/renderer/vt/state.cpp +++ b/src/renderer/vt/state.cpp @@ -158,6 +158,7 @@ void VtEngine::_flushImpl() noexcept { const auto fSuccess = WriteFile(_hFile.get(), _buffer.data(), gsl::narrow_cast(_buffer.size()), nullptr, nullptr); _buffer.clear(); + _startOfFrameBufferIndex = 0; if (!fSuccess) { LOG_LAST_ERROR(); diff --git a/src/renderer/vt/vtrenderer.hpp b/src/renderer/vt/vtrenderer.hpp index 0135e791169..0125fe17369 100644 --- a/src/renderer/vt/vtrenderer.hpp +++ b/src/renderer/vt/vtrenderer.hpp @@ -93,6 +93,7 @@ namespace Microsoft::Console::Render protected: wil::unique_hfile _hFile; std::string _buffer; + size_t _startOfFrameBufferIndex = 0; std::string _formatBuffer; std::string _conversionBuffer;