Skip to content

Commit

Permalink
fix: reset cursor position on renderer exit
Browse files Browse the repository at this point in the history
We need to reset the cursor position to the beginning of the line when
the program stops or exit.

Related: charmbracelet/gum#607
  • Loading branch information
aymanbagabas committed Jul 16, 2024
1 parent 72760ee commit e73870e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions standard_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ func (r *standardRenderer) stop() {
defer r.mtx.Unlock()

r.execute(ansi.EraseEntireLine)
// Move the cursor back to the beginning of the line
r.execute("\r")

if r.useANSICompressor {
if w, ok := r.out.(io.WriteCloser); ok {
Expand All @@ -132,6 +134,8 @@ func (r *standardRenderer) kill() {
defer r.mtx.Unlock()

r.execute(ansi.EraseEntireLine)
// Move the cursor back to the beginning of the line
r.execute("\r")
}

// listen waits for ticks on the ticker, or a signal to stop the renderer.
Expand Down

0 comments on commit e73870e

Please sign in to comment.