Skip to content

Commit

Permalink
Change to restore hidden cursor when auto spinning fails in ref issue #…
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmurach committed Nov 27, 2018
1 parent 51b2d5b commit 99ff64a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/tty/spinner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ def auto_spin
end
end
end
ensure
if @hide_cursor
write(TTY::Cursor.show, false)
end
end

# Checked if current spinner is paused
Expand Down
11 changes: 11 additions & 0 deletions spec/unit/auto_spin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,15 @@

expect(spinner).to have_received(:spin).at_least(5).times
end

it "restores cursor when erorr is raised" do
spinner = TTY::Spinner.new(output: output, hide_cursor: true)

spinner.auto_spin {
raise 'boom'
}

output.rewind
expect(output.read).to start_with("\e[?25l").and end_with("\e[?25h")
end
end

0 comments on commit 99ff64a

Please sign in to comment.