Skip to content

TextView.UpdateContentSize isn't working correctly on insert and delete text #4998

@BDisp

Description

@BDisp

Although caching fields improves performance, there are situations where it should be intelligently calculated only when truly necessary. This unit test prove this issue.

    [Fact]
    public void Typing_ShiftTab_At_End_Of_Line_With_Wrap_Disabled_Should_Scroll_Horizontally_And_Update_Content_Size ()
    {
        TextView tv = new ()
        {
            Width = 5,
            Height = 2,
            Text = "Line1\t\nLine2\nLine3"
        };
        tv.BeginInit ();
        tv.EndInit ();

        tv.InsertionPoint = new Point (9, 0);
        Assert.Equal (new Point (4, 0), tv.Viewport.Location);
        Assert.Equal (new Point (6, 0), tv.InsertionPoint);
        Assert.Equal (new Size (9, 3), tv.GetContentSize ());

        tv.NewKeyDownEvent (Key.Tab.WithShift);

        Assert.Equal (new Point (1, 0), tv.Viewport.Location);
        Assert.Equal (new Point (5, 0), tv.InsertionPoint);
        Assert.Equal (new Size (6, 3), tv.GetContentSize ());
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions