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

fix: combining both conditional and unconditional wrapping #275

Merged
merged 5 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions get.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ func (s Style) getAsTransform(k propKey) func(string) string {
// Split a string into lines, additionally returning the size of the widest
// line.
func getLines(s string) (lines []string, widest int) {
s = strings.ReplaceAll(s, "\t", " ")
aymanbagabas marked this conversation as resolved.
Show resolved Hide resolved
lines = strings.Split(s, "\n")

for _, l := range lines {
Expand Down
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-20240329185201-62a6965a9fad
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-20240329185201-62a6965a9fad h1:ixybSpyIZys0qK4JF0asuuxdr9fMXHrOQa7/G9eO+nc=
github.com/charmbracelet/x/exp/term v0.0.0-20240329185201-62a6965a9fad/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 @@
// 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.Wrap(str, wrapAt, "")
}

// Render core text
Expand Down Expand Up @@ -339,7 +338,7 @@
}

// Padding
if !inline {

Check failure on line 341 in style.go

View workflow job for this annotation

GitHub Actions / lint-soft

`if !inline` has complex nested blocks (complexity: 8) (nestif)
if leftPadding > 0 {
var st *termenv.Style
if colorWhitespace || styleWhitespace {
Expand Down
Loading