瀏覽代碼

Fixes #4449. Regression in IsLegacyConsole mode where dirty cells are not handled correctly (#4451)

* Fixes #4449. Regression in IsLegacyConsole mode where dirty cells are not handled correctly

* Cursor position is always set in the beginning a new row or on non-dirty flags
BDisp 1 周之前
父節點
當前提交
5e3175cd9d
共有 2 個文件被更改,包括 3 次插入19 次删除
  1. 2 18
      Terminal.Gui/Drivers/OutputBase.cs
  2. 1 1
      Tests/UnitTestsParallelizable/Drivers/OutputBaseTests.cs

+ 2 - 18
Terminal.Gui/Drivers/OutputBase.cs

@@ -67,22 +67,6 @@ public abstract class OutputBase
         Attribute? redrawAttr = null;
         int lastCol = -1;
 
-        if (IsLegacyConsole)
-        {
-            // BUGBUG: This is a workaround for some regression in legacy console mode where
-            // BUGBUG: dirty cells are not handled correctly. Mark all cells dirty as a workaround.
-            lock (buffer.Contents!)
-            {
-                for (var row = 0; row < buffer.Rows; row++)
-                {
-                    for (var c = 0; c < buffer.Cols; c++)
-                    {
-                        buffer.Contents [row, c].IsDirty = true;
-                    }
-                }
-            }
-        }
-
         SetCursorVisibility (CursorVisibility.Invisible);
 
         for (int row = top; row < rows; row++)
@@ -117,6 +101,8 @@ public abstract class OutputBase
                             lastCol++;
                         }
 
+                        SetCursorPositionImpl (lastCol, row);
+
                         continue;
                     }
 
@@ -296,8 +282,6 @@ public abstract class OutputBase
 
     private void WriteToConsole (StringBuilder output, ref int lastCol, int row, ref int outputWidth)
     {
-        SetCursorPositionImpl (lastCol, row);
-
         if (IsLegacyConsole)
         {
             Write (output);

+ 1 - 1
Tests/UnitTestsParallelizable/Drivers/OutputBaseTests.cs

@@ -151,7 +151,7 @@ public class OutputBaseTests
         Assert.False (buffer.Contents! [0, 2].IsDirty);
 
         // Verify SetCursorPositionImpl was invoked by WriteToConsole (cursor set to a written column)
-        Assert.Equal (new Point (0, 0), output.GetCursorPosition ());
+        Assert.Equal (new Point (2, 0), output.GetCursorPosition ());
     }
 
     [Theory]