Skip to content

Conversation

@BlazeFace
Copy link
Contributor

@BlazeFace BlazeFace commented Apr 14, 2024

fixes #1390

  • I have read the Contribution Guidelines
  • I have commented on the issue above and discussed the intended changes
  • A maintainer has signed off on the changes and the issue was assigned to me
  • All newly added code is adequately covered by tests
  • All existing tests are still running without errors
  • The documentation was modified to reflect the changes OR no documentation changes are required.

Changes

Updated the ratio calculation to round up if the remainder is within 0.9999 I have tested this with a good amount of examples and it still works, but I have not written any proof that this will remain correct at any value. We could use a much smaller target to round say .99 as well.


Please upvote 👍 this pull request if you are interested in it.

@BlazeFace
Copy link
Contributor Author

@patriksvensson The only major modification I was considering was a bounds check to see if the total height could go over the target, do you think that is needed?

@FrankRay78 FrankRay78 self-assigned this Jul 31, 2024
@FrankRay78 FrankRay78 self-requested a review July 31, 2024 11:20
@FrankRay78 FrankRay78 added this to the 0.49 milestone Jul 31, 2024
@FrankRay78
Copy link
Contributor

I'll review this @BlazeFace

@FrankRay78 FrankRay78 changed the title Fixing #1390 Fix incorrect panel height calculation in complex layout Aug 1, 2024
@patriksvensson patriksvensson modified the milestones: 0.49, 0.50 Sep 2, 2024
@FrankRay78 FrankRay78 added the bug Something isn't working label Oct 24, 2024
@FrankRay78 FrankRay78 assigned BlazeFace and unassigned FrankRay78 Oct 24, 2024
@BlazeFace
Copy link
Contributor Author

@FrankRay78 if we are looking to merge this I can go ahead and rebase and resolve conflicts.

@FrankRay78
Copy link
Contributor

I would like to merge this. A few minor nits to add to a review, which I will do soon, but definitely go ahead and rebase please.

# Conflicts:
#	src/Tests/Spectre.Console.Tests/Expectations/Widgets/Layout/Render_Layout_With_Three_And_One_Columns.Output.verified.txt
@BlazeFace
Copy link
Contributor Author

@FrankRay78 Rebase complete

return Verifier.Verify(console.Output);
}

[Fact]
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we make this a [Theory] and pass in the problematic console heights 17, 20, 23, 28, 31 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

}

[Fact]
[Expectation("Render_Layout_With_Three_And_One_Columns")]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this/the underlying expectation file should probably be renamed to Render_Layout_With_Nested_Three_Rows_In_One_Column, to be more consistent with:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!


[Fact]
[Expectation("Render_Layout_With_Three_And_One_Columns")]
public Task Should_Render_Layout_With_Three_And_One_Columns()
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please move this to line 156, so your test follows directly after public Task Should_Render_Layout_With_Nested_Rows_And_Columns(), which is a natural grouping.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

foreach (var l in layouts)
{
l.Update(panel);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I've thought about this, and whilst I'm happy with the correctness of the above test, all the other tests in the same file use a fluent convention. Can you please have a go at updating your test to be in the same style as the others, here's a close example to follow (I'm sorry for this 🏈 ache request, and I know the test comes direct from the issue repro code):

    public Task Should_Render_Layout_With_Nested_Rows_And_Columns()
    {
        // Given
        var console = new TestConsole().Size(new Size(40, 15));
        var layout = new Layout()
            .SplitRows(
                new Layout("Top")
                    .SplitRows(
                        new Layout("T1")
                            .SplitColumns(
                                new Layout("A"),
                                new Layout("B")),
                        new Layout("T2")
                            .SplitColumns(
                                new Layout("C"),
                                new Layout("D"))),
                new Layout("Bottom")
                    .SplitRows(
                        new Layout("B1")
                            .SplitColumns(
                                new Layout("E"),
                                new Layout("F")),
                        new Layout("B2")
                            .SplitColumns(
                                    new Layout("G"),
                                    new Layout("H"))));

        // When
        console.Write(layout);

        // Then
        return Verifier.Verify(console.Output);
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

Copy link
Contributor

@FrankRay78 FrankRay78 left a comment

Choose a reason for hiding this comment

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

Hello @BlazeFace, if you'll be kind enough to entertain my review feedback, I'll be most kind enough to merge the PR once done. (So you know your efforts won't languish in an unmerged PR).

@FrankRay78
Copy link
Contributor

Thanks @BlazeFace, I've seen lots of activity but not had the time to look just yet. But I will do so soon.

Copy link
Contributor

@patriksvensson patriksvensson left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@FrankRay78
Copy link
Contributor

Good stuff @BlazeFace. Don't hesitate to tag me when you have other PRs to review.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panel in layout adds newline in more complex layout split

3 participants