瀏覽代碼

Change Cleanup to not call SetConsoleOutputWindow

Tigger Kindel 2 年之前
父節點
當前提交
ba01db3e8c
共有 2 個文件被更改,包括 10 次插入8 次删除
  1. 9 8
      Terminal.Gui/ConsoleDrivers/WindowsDriver.cs
  2. 1 0
      Terminal.Gui/Core/Application.cs

+ 9 - 8
Terminal.Gui/ConsoleDrivers/WindowsDriver.cs

@@ -164,7 +164,8 @@ namespace Terminal.Gui {
 				SetCursorVisibility (initialCursorVisibility.Value);
 			}
 
-			SetConsoleOutputWindow (out _);
+			// BUGBUG: Commenting this out fixes #2634
+			//SetConsoleOutputWindow (out _);
 
 			ConsoleMode = originalConsoleMode;
 			//ContinueListeningForConsoleEvents = false;
@@ -173,8 +174,9 @@ namespace Terminal.Gui {
 				Console.WriteLine ("Error: {0}", err);
 			}
 
-			if (ScreenBuffer != IntPtr.Zero)
+			if (ScreenBuffer != IntPtr.Zero) {
 				CloseHandle (ScreenBuffer);
+			}
 
 			ScreenBuffer = IntPtr.Zero;
 		}
@@ -1494,7 +1496,7 @@ namespace Terminal.Gui {
 				// If n is 2, clear entire screen (and moves cursor to upper left on DOS ANSI.SYS).
 				// If n is 3, clear entire screen and delete all lines saved in the scrollback buffer
 				// DO NOT USE 3J - even with the alternate screen buffer, it clears the entire scrollback buffer
-				Console.Out.Write ("\x1b[3J");
+				Console.Out.Write ("\x1b[0J");
 			}
 		}
 
@@ -1707,20 +1709,19 @@ namespace Terminal.Gui {
 
 		public override void End ()
 		{
+
 			WinConsole.Cleanup ();
 			WinConsole = null;
 
+			// Disable alternative screen buffer.
+			Console.Out.Write ("\x1b[?1047l");
+
 			// Needed for Windows Terminal
 			// Clear the alternative screen buffer from the cursor to the
 			// end of the screen.
 			// Note, [3J causes Windows Terminal to wipe out the entire NON ALTERNATIVE
 			// backbuffer! So we need to use [0J instead.
 			Console.Out.Write ("\x1b[0J");
-
-			// Disable alternative screen buffer.
-			Console.Out.Write ("\x1b[?1047l");
-
-			// Console.Out.Flush () is not needed. See https://stackoverflow.com/a/20450486/297526
 		}
 
 		/// <inheritdoc/>

+ 1 - 0
Terminal.Gui/Core/Application.cs

@@ -1103,6 +1103,7 @@ namespace Terminal.Gui {
 			// Init created. Apps that do any threading will need to code defensively for this.
 			// e.g. see Issue #537
 			foreach (var t in toplevels) {
+				
 				t.Running = false;
 				t.Dispose ();
 			}