Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
restore cursor on error (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
noerw committed Mar 10, 2021
1 parent eae2781 commit c79c4a9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions terminal/cursor.go
Expand Up @@ -167,8 +167,11 @@ func (c *Cursor) Size(buf *bytes.Buffer) (*Coord, error) {

// hide the cursor (so it doesn't blink when getting the size of the terminal)
c.Hide()
defer c.Show()

// save the current location of the cursor
c.Save()
defer c.Restore()

// move the cursor to the very bottom of the terminal
c.Move(999, 999)
Expand All @@ -179,11 +182,6 @@ func (c *Cursor) Size(buf *bytes.Buffer) (*Coord, error) {
return nil, err
}

// move back where we began
c.Restore()

// show the cursor
c.Show()
// since the bottom was calculated in the lower right corner, it
// is the dimensions we are looking for
return bottom, nil
Expand Down

0 comments on commit c79c4a9

Please sign in to comment.