Skip to content

Commit

Permalink
fix: combining both conditional and unconditional wrapping
Browse files Browse the repository at this point in the history
Uses `ansi.SmartWrap` charmbracelet/x#57

Fixes: muesli/reflow#43
  • Loading branch information
aymanbagabas committed Mar 28, 2024
1 parent 9a9f026 commit e45b7be
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ retract v0.7.0 // v0.7.0 introduces a bug that causes some apps to freeze.
go 1.18

require (
github.com/charmbracelet/x/exp/term v0.0.0-20240328150354-ab9afc214dfd
github.com/charmbracelet/x/exp/term v0.0.0-20240328180709-6b796dc78d2d
github.com/muesli/termenv v0.15.2
github.com/rivo/uniseg v0.4.7
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/charmbracelet/x/exp/term v0.0.0-20240328150354-ab9afc214dfd h1:HqBjkSFXXfW4IgX3TMKipWoPEN08T3Pi4SA/3DLss/U=
github.com/charmbracelet/x/exp/term v0.0.0-20240328150354-ab9afc214dfd/go.mod h1:6GZ13FjIP6eOCqWU4lqgveGnYxQo9c3qBzHPeFu4HBE=
github.com/charmbracelet/x/exp/term v0.0.0-20240328180709-6b796dc78d2d h1:OTGSTcRfFHZ8QOVhdHUW0Qwi2UBsH7QQnJ++uwtbwFE=
github.com/charmbracelet/x/exp/term v0.0.0-20240328180709-6b796dc78d2d/go.mod h1:6GZ13FjIP6eOCqWU4lqgveGnYxQo9c3qBzHPeFu4HBE=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
Expand Down
3 changes: 1 addition & 2 deletions style.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,7 @@ func (s Style) Render(strs ...string) string {
// Word wrap
if !inline && width > 0 {
wrapAt := width - leftPadding - rightPadding
str = ansi.Wordwrap(str, wrapAt, "")
str = ansi.Wrap(str, wrapAt, false) // force-wrap long strings
str = ansi.SmartWrap(str, wrapAt, "")
}

// Render core text
Expand Down

0 comments on commit e45b7be

Please sign in to comment.