diff --git a/src/buffer/out/cursor.cpp b/src/buffer/out/cursor.cpp index 46f0208f8..1d050a215 100644 --- a/src/buffer/out/cursor.cpp +++ b/src/buffer/out/cursor.cpp @@ -315,6 +315,11 @@ void Cursor::StartDeferDrawing() noexcept _fDeferCursorRedraw = true; } +bool Cursor::IsDeferDrawing() noexcept +{ + return _fDeferCursorRedraw; +} + void Cursor::EndDeferDrawing() noexcept { if (_fHaveDeferredCursorRedraw) diff --git a/src/buffer/out/cursor.h b/src/buffer/out/cursor.h index 7ac93359a..dbd05f535 100644 --- a/src/buffer/out/cursor.h +++ b/src/buffer/out/cursor.h @@ -55,6 +55,7 @@ public: const COLORREF GetColor() const noexcept; void StartDeferDrawing() noexcept; + bool IsDeferDrawing() noexcept; void EndDeferDrawing() noexcept; void SetHasMoved(const bool fHasMoved) noexcept; diff --git a/src/cascadia/TerminalCore/Terminal.cpp b/src/cascadia/TerminalCore/Terminal.cpp index 666068cb0..9cc4aea47 100644 --- a/src/cascadia/TerminalCore/Terminal.cpp +++ b/src/cascadia/TerminalCore/Terminal.cpp @@ -1070,7 +1070,12 @@ void Terminal::_AdjustCursorPosition(const COORD proposedPosition) _buffer->GetRenderTarget().TriggerScroll(&delta); } - _NotifyTerminalCursorPositionChanged(); + // Firing the CursorPositionChanged event is very expensive so we try not to do that when + // the cursor does not need to be redrawn. + if (!cursor.IsDeferDrawing()) + { + _NotifyTerminalCursorPositionChanged(); + } } void Terminal::UserScrollViewport(const int viewTop)