Skip to content

Commit

Permalink
fix: ansi.Wrap issue with a limit of 1 (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
pachecot authored Oct 11, 2024
1 parent 7cc13b2 commit 4604409
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ansi/wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ func Wrap(s string, limit int, breakpoints string) string {
curWidth++
}
default:
if curWidth == limit {
addNewline()
}
word.WriteRune(r)
wordLen++

Expand Down
1 change: 1 addition & 0 deletions ansi/wrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var cases = []struct {
{"preserve_style", "\x1B[38;2;249;38;114m(\x1B[0m\x1B[38;2;248;248;242mjust another test\x1B[38;2;249;38;114m)\x1B[0m", 3, "\x1B[38;2;249;38;114m(\x1B[0m\x1B[38;2;248;248;242mju\nst \nano\nthe\nr t\nest\x1B[38;2;249;38;114m\n)\x1B[0m", false},
{"emoji", "foo🫧foobar", 4, "foo\n🫧fo\nobar", false},
{"osc8_wrap", "สวัสดีสวัสดี\x1b]8;;https://example.com\x1b\\สวัสดีสวัสดี\x1b]8;;\x1b\\", 8, "สวัสดีสวัสดี\x1b]8;;https://example.com\x1b\\\nสวัสดีสวัสดี\x1b]8;;\x1b\\", false},
{"column", "VERTICAL", 1, "V\nE\nR\nT\nI\nC\nA\nL", false},
}

func TestHardwrap(t *testing.T) {
Expand Down

0 comments on commit 4604409

Please sign in to comment.