Skip to content

Commit

Permalink
fix(cellbuf): SetContent should truncate the string if it doesn't fit…
Browse files Browse the repository at this point in the history
… in the window
  • Loading branch information
aymanbagabas committed Jan 7, 2025
1 parent 7531ec9 commit cbdcc21
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cellbuf/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (c *Window) SetContent(s string) {
s = strings.ReplaceAll(s, "\n", "\r\n")
c.Clear()
c.MoveTo(0, 0)
c.Print(s)
c.PrintTruncate(s, "")
}

// Fill fills the window with the given cell and resets the cursor position,
Expand Down Expand Up @@ -275,7 +275,7 @@ func (c *Window) drawString(s string, x, y int, opts *drawOpts) {
cell = newGraphemeCell(seq, width)
}

if !opts.truncate && x >= c.w {
if !opts.truncate && x+width > c.x+c.w {
// Auto wrap the cursor.
wrapCursor()
if y >= c.h {
Expand Down

0 comments on commit cbdcc21

Please sign in to comment.