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

Commit c79c4a9

Browse files
authored
restore cursor on error (#337)
1 parent eae2781 commit c79c4a9

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

terminal/cursor.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,11 @@ func (c *Cursor) Size(buf *bytes.Buffer) (*Coord, error) {
167167

168168
// hide the cursor (so it doesn't blink when getting the size of the terminal)
169169
c.Hide()
170+
defer c.Show()
171+
170172
// save the current location of the cursor
171173
c.Save()
174+
defer c.Restore()
172175

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

182-
// move back where we began
183-
c.Restore()
184-
185-
// show the cursor
186-
c.Show()
187185
// since the bottom was calculated in the lower right corner, it
188186
// is the dimensions we are looking for
189187
return bottom, nil

0 commit comments

Comments
 (0)