Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panel cut off in layout when lines are wrapped around #1569

Open
vzam opened this issue Jun 14, 2024 · 3 comments
Open

Panel cut off in layout when lines are wrapped around #1569

vzam opened this issue Jun 14, 2024 · 3 comments
Labels
bug Something isn't working needs triage

Comments

@vzam
Copy link

vzam commented Jun 14, 2024

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 👍 this issue if you are interested in it.

@vzam vzam added bug Something isn't working needs triage labels Jun 14, 2024
@patriksvensson
Copy link
Contributor

I'm sorry, I don't understand. Why would the expected behaviour be to show six lines when the console is four lines high?

@patriksvensson
Copy link
Contributor

Panels are limited to the layout that they exist within. this is by design.

@vzam
Copy link
Author

vzam commented Jun 14, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
Status: Todo 🕑
Development

No branches or pull requests

2 participants