Panel cut off in layout when lines are wrapped around
Information
- OS: MacOS
- Version: 0.49.1
- Terminal: iTerm
Describe the bug
When rendering a Panel, if the content is too wide for the terminal, it will wrap to the next line within the panel. This behavior is tested in PanelTests.Should_Use_Max_Width_If_Specified_Width_Is_Too_Large.
However, when a Panel is placed within a Layout, the layout restricts the panel's height to the console's height. Consequently, the Segment.SplitLines method truncates any lines that exceed this height. This results in inconsistency because if a standalone panel exceeds the console height, it prints entirely, requiring you to scroll up. But within a layout, only the initial portion is printed, and the rest is truncated from the output.
To Reproduce Run this test:
// Given
var console = new TestConsole().Size(new Size(20, 2 + 2)); // only space for 2 lines plus 2 because of the border
var panel = new Panel(new Text("Lorem ipsum dolor sit amet, consectetur odio.")); // the text has 4 lines
var layout = new Layout().Update(panel);
// When
console.Write(layout);
// Then
return Verifier.Verify(console.Output);
This will print the following to the console:
┌──────────────────┐
│ Lorem ipsum │
│ dolor sit amet, │
│ consectetur │
Expected behavior The console contains:
┌──────────────────┐
│ Lorem ipsum │
│ dolor sit amet, │
│ consectetur │
│ odio. │
└──────────────────┘
where the only lower bit is visible because the content exceeds the height of the console.
Please upvote :+1: this issue if you are interested in it.
I'm sorry, I don't understand. Why would the expected behaviour be to show six lines when the console is four lines high?
Panels are limited to the layout that they exist within. this is by design.
I apologise if this is the expected behaviour. In my use case, I have a layout with two columns showing a bunch of text and I don't really care if it exceeds the height of the console. This is an interactive tool and I expect the user to scroll up if they miss something. The layout as far as I know always adjusts to the height of the console and I could set the height explicitly based on the number of lines I want to show in each panel but I don't know in advance if there are any lines which wrap around and thus increase the height requirement. Can you give me any hints on how to implement this or are you open for contributions addressing this particular issue?