Skip to content

Commit

Permalink
fix(cellbuf): REP should put the first character before the sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Dec 9, 2024
1 parent 33c9d4f commit 1a994bf
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions cellbuf/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ type Screen struct {
pos Position // the position of the cursor after the last render
opts ScreenOptions
mu sync.Mutex
lastChar rune // the last character written to the screen
altScreenMode bool // whether alternate screen mode is enabled
cursorHidden bool // whether text cursor mode is enabled
clear bool // whether to force clear the screen
Expand Down Expand Up @@ -445,7 +444,6 @@ func (s *Screen) putCell(w io.Writer, cell *Cell) {
s.updatePen(w, cell)
io.WriteString(w, cell.String()) //nolint:errcheck
s.cur.X += cell.Width
s.lastChar = cell.Rune

if s.cur.X >= s.newbuf.Width() {
s.cur.X = s.newbuf.Width() - 1
Expand Down Expand Up @@ -532,14 +530,8 @@ func (s *Screen) emitRange(w io.Writer, line Line, n int) (eoi bool) {
repCount--
}

if runes[0] != s.lastChar {
cellWidth := 1
if cell0 != nil {
cellWidth = cell0.Width
}
s.putCell(w, cell0)
repCount -= cellWidth
}
s.putCell(w, cell0)
repCount-- // cell0 is a single width cell ASCII character

s.updatePen(w, cell0)
io.WriteString(w, ansi.RepeatPreviousCharacter(repCount)) //nolint:errcheck
Expand Down Expand Up @@ -1130,7 +1122,6 @@ func (s *Screen) Close() (err error) {

// reset resets the screen to its initial state.
func (s *Screen) reset() {
s.lastChar = -1
s.cursorHidden = false
s.altScreenMode = false
if s.opts.RelativeCursor {
Expand Down

0 comments on commit 1a994bf

Please sign in to comment.