From 47eb43fd6ef9f65b760b64b7a532def0f3ff7e03 Mon Sep 17 00:00:00 2001 From: BDisp Date: Tue, 21 Feb 2023 00:55:07 +0000 Subject: [PATCH] Fixes 2368. Nested views with height of 1 not rendering correctly. (#2370) --- Terminal.Gui/Core/TextFormatter.cs | 4 ++-- UnitTests/Views/ViewTests.cs | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Terminal.Gui/Core/TextFormatter.cs b/Terminal.Gui/Core/TextFormatter.cs index 2e5c84ebe..e6e1592e3 100644 --- a/Terminal.Gui/Core/TextFormatter.cs +++ b/Terminal.Gui/Core/TextFormatter.cs @@ -1190,8 +1190,8 @@ namespace Terminal.Gui { for (int line = 0; line < linesFormated.Count; line++) { if ((isVertical && line > bounds.Width) || (!isVertical && line > bounds.Height)) continue; - if ((isVertical && line >= maxBounds.Left + maxBounds.Width - 1) - || (!isVertical && line >= maxBounds.Top + maxBounds.Height - 1)) + if ((isVertical && line >= maxBounds.Left + maxBounds.Width) + || (!isVertical && line >= maxBounds.Top + maxBounds.Height)) break; diff --git a/UnitTests/Views/ViewTests.cs b/UnitTests/Views/ViewTests.cs index 01c1f19ad..1cfc1296b 100644 --- a/UnitTests/Views/ViewTests.cs +++ b/UnitTests/Views/ViewTests.cs @@ -1,5 +1,6 @@ using NStack; using System; +using Terminal.Gui.Graphs; using Xunit; using Xunit.Abstractions; //using GraphViewTests = Terminal.Gui.Views.GraphViewTests; @@ -4489,5 +4490,31 @@ At 0,0 A text with some long width A text witith two lines. ", output); } + + [Fact, AutoInitShutdown] + public void Test_Nested_Views_With_Height_Equal_To_One () + { + var v = new View () { Width = 11, Height = 3, ColorScheme = new ColorScheme () }; + + var top = new View () { Width = Dim.Fill (), Height = 1 }; + var bottom = new View () { Width = Dim.Fill (), Height = 1, Y = 2 }; + + top.Add (new Label ("111")); + v.Add (top); + v.Add (new LineView (Orientation.Horizontal) { Y = 1 }); + bottom.Add (new Label ("222")); + v.Add (bottom); + + v.LayoutSubviews (); + v.Redraw (v.Bounds); + + + string looksLike = +@" +111 +─────────── +222"; + TestHelpers.AssertDriverContentsAre (looksLike, output); + } } }