⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 28, 2026

When Console.BufferWidth is set larger than Console.WindowWidth, test progress timings display incorrectly or not at all. MTP uses ANSI cursor positioning to place timings on the right edge, but was calculating positions using BufferWidth instead of WindowWidth.

Changes

IConsole interface

  • Added WindowWidth and WindowHeight properties

Terminal implementations

  • SimpleTerminal and AnsiTerminal now use WindowWidth/WindowHeight instead of BufferWidth/BufferHeight for their Width/Height properties
  • ANSI cursor positioning now operates within visible window bounds

Tests

  • Added SimpleTerminal_UsesWindowWidthNotBufferWidth and AnsiTerminal_UsesWindowWidthNotBufferWidth to verify behavior when buffer ≠ window dimensions
  • Updated test mocks to implement new interface properties

Example scenario

// Setting large buffer width (e.g., in Windows Terminal)
Console.BufferWidth = 4096;  // Buffer width
// Console.WindowWidth = 120; // Actual visible width

// Before: Cursor positioned at column 4096 - timing_length (off-screen)
// After:  Cursor positioned at column 120 - timing_length (visible)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 5rqvsblobprodcus385.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/testfx/testfx/.dotnet/dotnet /home/REDACTED/work/testfx/testfx/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:minimal /nr:true /warnaserror /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=false /home/REDACTED/work/testfx/testfx/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/testfx/testfx/artifacts/toolset/11.0.0-beta.26077.1.txt (dns block)
    • Triggering command: /usr/bin/dotnet dotnet build src/Platform/Microsoft.Testing.Platform/Microsoft.Testing.Platform.csproj -c Release kload.emscripten.net9 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Microsoft Testing Platform does not handle large BufferWidth in console</issue_title>
<issue_description>## Describe the bug

When Console.BufferWidth is set to a larger value than the Console.WindowWidth, the running test timing is not displayed correctly (or at all).

If using Windows Terminal, the output is messed up. If using conhost.exe, then the timings do not appear.

Steps To Reproduce

Using TUnit:

dotnet new console
dotnet add package tunit

Add the following test fixture:

using System.Runtime.InteropServices;

public class Fixture
{
    [Test]
    public async Task Test1()
    {
        await Task.Delay(TimeSpan.FromSeconds(2));

        if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            Console.BufferWidth = 4096;

        await Task.Delay(TimeSpan.FromSeconds(2));
    }

    [Test]
    public Task Test2() => Task.Delay(TimeSpan.FromSeconds(3));
}

Expected behavior

I expect to be able to see the timings as intended while the tests are running (i.e., updated every few seconds, but then removed after the final test run completes).

Actual behavior

If using Windows Terminal, the output is skewed:

testfx_wt.mp4

If using conhost.exe, the timing is not visible.

Additional context

Testing platform is using ANSI codes to position the cursor at the right-hand side of the screen. However, the calculations are done using Console.BufferWidth ... should they perhaps be using Console.WindowWidth to position the output of the test timing?

Or perhaps the timings should be moved to the beginning of the updating output so there's no reliance on the screen/buffer width calculations?
</issue_description>

<agent_instructions>Assess if the analysis of the issue is correct, if that's the case suggest a fix and ensure to have tests to avoid regressions</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 28, 2026 18:07
…l positioning

Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix console output for large BufferWidth values Fix cursor positioning when Console.BufferWidth exceeds Console.WindowWidth Jan 28, 2026
Copilot AI requested a review from Evangelink January 28, 2026 18:15
@@ -507,6 +507,10 @@ internal class StringBuilderConsole : IConsole

public int BufferWidth => int.MinValue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks weird, looks like a typo, probably should have been MaxValue? Interesting that the current tests (before this change) work.


public int WindowHeight => int.MaxValue;

public int WindowWidth => 120;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be MaxValue as well, as it limits the size of the screen and we probably don't want to test shortening in any of the general test cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Microsoft Testing Platform does not handle large BufferWidth in console

3 participants