-
Notifications
You must be signed in to change notification settings - Fork 292
Fix cursor positioning when Console.BufferWidth exceeds Console.WindowWidth #7305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 4 commits
51c538a
f208e6c
1ce3146
ed07bd9
e5f9738
5d868e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -507,6 +507,10 @@ | |
|
|
||
| public int BufferWidth => int.MinValue; | ||
|
|
||
| public int WindowHeight => int.MaxValue; | ||
|
|
||
| public int WindowWidth => 120; | ||
Evangelink marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| public bool IsOutputRedirected => false; | ||
|
|
||
| public string Output => _output.ToString(); | ||
|
|
@@ -809,4 +813,65 @@ | |
| // Assert - should contain information about 2 tests discovered | ||
| Assert.IsTrue(output.Contains('2') || output.Contains("TestMethod1"), "Output should contain information about discovered tests"); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void SimpleTerminal_UsesWindowWidthNotBufferWidth() | ||
| { | ||
| // Arrange - Create a console where BufferWidth and WindowWidth are different | ||
| var console = new TestConsoleWithDifferentBufferAndWindowWidth | ||
| { | ||
| BufferWidth = 4096, | ||
| WindowWidth = 120 | ||
|
Check failure on line 824 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs
|
||
Evangelink marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| var terminal = new NonAnsiTerminal(console); | ||
|
|
||
| // Assert - Width should use WindowWidth, not BufferWidth | ||
| Assert.AreEqual(120, terminal.Width); | ||
| } | ||
|
|
||
| [TestMethod] | ||
| public void AnsiTerminal_UsesWindowWidthNotBufferWidth() | ||
| { | ||
| // Arrange - Create a console where BufferWidth and WindowWidth are different | ||
| var console = new TestConsoleWithDifferentBufferAndWindowWidth | ||
| { | ||
| BufferWidth = 4096, | ||
| WindowWidth = 120 | ||
|
Check failure on line 840 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs
|
||
Evangelink marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }; | ||
|
|
||
| var terminal = new AnsiTerminal(console); | ||
|
|
||
| // Assert - Width should use WindowWidth, not BufferWidth | ||
| Assert.AreEqual(120, terminal.Width); | ||
| } | ||
|
|
||
| internal class TestConsoleWithDifferentBufferAndWindowWidth : IConsole | ||
| { | ||
| public int BufferHeight { get; set; } = 300; | ||
|
|
||
| public int BufferWidth { get; set; } = 4096; | ||
|
|
||
| public int WindowHeight { get; set; } = 30; | ||
|
|
||
| public int WindowWidth { get; set; } = 120; | ||
|
|
||
| public bool IsOutputRedirected => false; | ||
|
|
||
| public event ConsoleCancelEventHandler? CancelKeyPress = (sender, e) => { }; | ||
|
|
||
| public void Clear() => throw new NotImplementedException(); | ||
|
|
||
| public ConsoleColor GetForegroundColor() => ConsoleColor.White; | ||
|
|
||
| public void SetForegroundColor(ConsoleColor color) { } | ||
|
Check failure on line 867 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs
|
||
|
|
||
| public void Write(string? value) { } | ||
|
Check failure on line 869 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs
|
||
|
|
||
| public void Write(char value) { } | ||
|
Check failure on line 871 in test/UnitTests/Microsoft.Testing.Platform.UnitTests/OutputDevice/Terminal/TerminalTestReporterTests.cs
|
||
|
|
||
| public void WriteLine() { } | ||
|
|
||
| public void WriteLine(string? value) { } | ||
Evangelink marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.