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
noerw authored Mar 10, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent eae2781 commit c79c4a9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions terminal/cursor.go
Original file line number Diff line number Diff line change
@@ -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)
@@ -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

0 comments on commit c79c4a9

Please sign in to comment.