Skip to content

TextFormatter bugs #3418

@tig

Description

@tig

This API is described as:

    /// <summary>
    ///     Returns the number of columns in the widest line in the list based on the <paramref name="startIndex"/> and
    ///     the <paramref name="length"/>.
    /// </summary>
    /// <remarks>
    ///     This API will return incorrect results if the text includes glyphs who's width is dependent on surrounding
    ///     glyphs (e.g. Arabic).
    /// </remarks>
    /// <param name="lines">The lines.</param>
    /// <param name="startIndex">The start index.</param>
    /// <param name="length">The length.</param>
    /// <param name="tabWidth">The number of columns used for a tab.</param>
    /// <returns>The maximum characters width.</returns>
    public static int GetWidestLineLength (
        List<string> lines,
        int startIndex = -1,
        int length = -1,
        int tabWidth = 0
    )

Based on this, this unit test should pass. It doesn't. The actual width returned is 1.

    [Theory]
    [InlineData (new [] { "0123456789" }, 10)]
    public void GetWidestLineLength_List_GetsWidth (IEnumerable<string> text, int expectedWidth
    )
    {
        Assert.Equal (expectedWidth, TextFormatter.GetWidestLineLength (text.ToList ()));
    }

I'm massively confused. Perhaps the API docs are completely wrong?

@BDisp can you advise?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions