Repository: microsoft/terminal (language: cpp)

Issue:
Unused/obsolete code in XtermEngine
In the `XtermEngine::StartPaint` method, there's some code that calculates the dirty area here:
https://github.com/microsoft/terminal/blob/183a8956f699e1967d4cb4712184d0dbc395a0e5/src/renderer/vt/XtermEngine.cpp#L85-L97

However, the result of that calculation is not actually used. There was a time when there was more code in that branch that compared the dirty area against the last viewport, but that was removed in PR #4741.

---

And in the `XtermEngine::_MoveCursor` method there's a local variable `performedSoftWrap` which is initially set to false at the start of the method here:

https://github.com/microsoft/terminal/blob/183a8956f699e1967d4cb4712184d0dbc395a0e5/src/renderer/vt/XtermEngine.cpp#L249-L249

And it's potentially changed to true later in the code:

https://github.com/microsoft/terminal/blob/183a8956f699e1967d4cb4712184d0dbc395a0e5/src/renderer/vt/XtermEngine.cpp#L273-L278

However, the variable is otherwise never read. It looks like it was added as part of PR #5181, but even then it doesn't appear to have been used.

Unless there is something I'm missing, I'd suggest we should remove the unused code.


Discussion / hints:

Fix patch:
diff --git a/src/renderer/vt/XtermEngine.cpp b/src/renderer/vt/XtermEngine.cpp
index 4df161befc1..0dc9c8384e4 100644
--- a/src/renderer/vt/XtermEngine.cpp
+++ b/src/renderer/vt/XtermEngine.cpp
@@ -81,20 +81,6 @@ XtermEngine::XtermEngine(_In_ wil::unique_hfile hPipe,
         _clearedAllThisFrame = true;
         _firstPaint = false;
     }
-    else
-    {
-        std::span<const til::rect> dirty;
-        RETURN_IF_FAILED(GetDirtyArea(dirty));
-
-        // If we have 0 or 1 dirty pieces in the area, set as appropriate.
-        auto dirtyView = dirty.empty() ? Viewport::Empty() : Viewport::FromExclusive(til::at(dirty, 0));
-
-        // If there's more than 1, union them all up with the 1 we already have.
-        for (size_t i = 1; i < dirty.size(); ++i)
-        {
-            dirtyView = Viewport::Union(dirtyView, Viewport::FromExclusive(til::at(dirty, i)));
-        }
-    }
 
     return S_OK;
 }
@@ -246,7 +232,6 @@ XtermEngine::XtermEngine(_In_ wil::unique_hfile hPipe,
     auto hr = S_OK;
     const auto originalPos = _lastText;
     _trace.TraceMoveCursor(_lastText, coord);
-    auto performedSoftWrap = false;
     if (coord.x != _lastText.x || coord.y != _lastText.y)
     {
         if (coord.x == 0 && coord.y == 0)
@@ -272,7 +257,6 @@ XtermEngine::XtermEngine(_In_ wil::unique_hfile hPipe,
 
             if (previousLineWrapped)
             {
-                performedSoftWrap = true;
                 _trace.TraceWrapped();
                 hr = S_OK;
             }


Test patch: