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

PlaceHorizontal(): Don't render the spaces on the right #447

Open
myaaaaaaaaa opened this issue Dec 1, 2024 · 1 comment
Open

PlaceHorizontal(): Don't render the spaces on the right #447

myaaaaaaaaa opened this issue Dec 1, 2024 · 1 comment

Comments

@myaaaaaaaaa
Copy link

Describe the bug
When resizing a terminal, lines that run the whole width will wrap to the next line, causing garbage to accumulate at the top:

a

It'd be nice if terminals could find a way to fix this, but for now, we might as well alleviate this problem by leaving room on the right whenever possible:

b

Fix should be fairly straightforward, something like this:

diff --git a/position.go b/position.go
index 185f5af..1a9a897 100644
--- a/position.go
+++ b/position.go
@@ -72,5 +72,4 @@ func (r *Renderer) PlaceHorizontal(width int, pos Position, str string, opts ...
 		case Left:
 			b.WriteString(l)
-			b.WriteString(ws.render(gap + short))
 
 		case Right:
@@ -87,5 +86,4 @@ func (r *Renderer) PlaceHorizontal(width int, pos Position, str string, opts ...
 			b.WriteString(ws.render(left))
 			b.WriteString(l)
-			b.WriteString(ws.render(right))
 		}
 
@myaaaaaaaaa
Copy link
Author

Alternatively, there's also the option of handling this on the bubbletea side - basically TrimRight()ing the whitespace from the return value of Model.View() before rendering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant