-
Notifications
You must be signed in to change notification settings - Fork 270
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
viewport line wrapping bug #644
Comments
What a coincindence. I discovered this exact same issue while trying to diagnose a line wrapping issue in the Select widget from |
Glad to know this is actually an issue and not just a skill issue on my part, I discovered it while working on a TUI for messaging, so this is a core functionality of what I am making. |
Hi! This is not entirely a bug: historically we've left wrapping as an exercise for the user. If you need to solve this now you can simply: wrapped := lipgloss.NewStyle().Width(yourWidth).Render(yourContent)
viewport.SetContent(wrapped) That said, we're tracking this in #578. |
Hey @Kyren223 this issue is more related to how we're handling content wrapping in our example rather than a bug with viewport. This is what to change from the chat example to have it work on window resize. I also added gap as a const so we wouldn't need magic numbers when calculating the available height.
Let me know if you still run into any issues! Otherwise I will close this one. |
Hey, I understand not accepting the PR due to breaking changes, but I wouldn't classify this as a question, it's a bug. If a component starts to behave weirdly (disappearing lines in a weird/unexpected way) when providing to it a string that has it's lipgloss width exceed the width of the component then I would call that a bug. If wrapping it is a breaking change then at least making the behavior consistent (like truncating and not displaying anything that exceeds the width), or even better to have truncation as default and some opt-in method to set it to wrap instead of truncate. |
Describe the bug
Multi-line (wrapped) text causes the viewport to not behave correctly, when using
viewport.Model#GotoBottom()
and updating the height of it (by resizing the terminal),Instead of hiding the top messages, it behaves weirdly and hides the bottom message.
Setup
Please complete the following information along with version numbers, if applicable.
To Reproduce
Steps to reproduce the behavior:
Source Code
A slightly modified version of the example "chat" code
Expected behavior
Actual behavior
Screenshots
Normal
After shrinking once (bottom line missing, both 1st and 2nd line of the top message exist)
The expected behaviour would be to either
After shrinking again (bottom line reappears, both the 1st and 2nd line of the top message disappear)
The text was updated successfully, but these errors were encountered: