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

restore cursor on error #337

Merged
merged 1 commit into from
Mar 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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