Skip to content

Commit

Permalink
fix(cellbuf): simplify logic for getting non-empty zero cells out
Browse files Browse the repository at this point in the history
Tidy and simplify the logic for getting non-empty zero cells out to
the terminal.
  • Loading branch information
aymanbagabas committed Feb 6, 2025
1 parent 0e0ce8f commit ac5dd4e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions cellbuf/screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,13 +615,15 @@ func (s *Screen) putAttrCell(cell *Cell) {
s.atPhantom = false
}

s.updatePen(cell)
s.buf.WriteRune(cell.Rune) //nolint:errcheck
for _, c := range cell.Comb {
s.buf.WriteRune(c) //nolint:errcheck
}

s.cur.X += cell.Width

if cell.Width > 0 {
s.updatePen(cell)
s.buf.WriteRune(cell.Rune) //nolint:errcheck
for _, c := range cell.Comb {
s.buf.WriteRune(c) //nolint:errcheck
}
s.cur.X += cell.Width
s.queuedText = true
}

Expand All @@ -634,13 +636,11 @@ func (s *Screen) putAttrCell(cell *Cell) {
func (s *Screen) putCellLR(cell *Cell) {
// Optimize for the lower right corner cell.
curX := s.cur.X
if cell == nil || cell.Width > 0 {
if cell == nil || !cell.Empty() {
s.buf.WriteString(ansi.ResetAutoWrapMode) //nolint:errcheck
}
s.putAttrCell(cell)
// Writing to lower-right corner cell should not wrap.
s.atPhantom = false
if cell == nil || cell.Width > 0 {
s.putAttrCell(cell)
// Writing to lower-right corner cell should not wrap.
s.atPhantom = false
s.cur.X = curX
s.buf.WriteString(ansi.SetAutoWrapMode) //nolint:errcheck
}
Expand Down

0 comments on commit ac5dd4e

Please sign in to comment.