Skip to content

Commit

Permalink
Merge pull request #404 from aycabta/finalize-when-exception-occurred
Browse files Browse the repository at this point in the history
Finalize when exception occurred
  • Loading branch information
aycabta committed Dec 20, 2021
2 parents 7e6f33e + 1f8a3ae commit 50ed575
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/reline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ def readline(prompt = '', add_hist = false)

may_req_ambiguous_char_width
line_editor.reset(prompt, encoding: Reline::IOGate.encoding)
line_editor.set_signal_handlers
if multiline
line_editor.multiline_on
if block_given?
Expand Down Expand Up @@ -320,6 +319,7 @@ def readline(prompt = '', add_hist = false)
line_editor.rerender

begin
line_editor.set_signal_handlers
prev_pasting_state = false
loop do
prev_pasting_state = Reline::IOGate.in_pasting?
Expand Down Expand Up @@ -348,6 +348,11 @@ def readline(prompt = '', add_hist = false)
line_editor.finalize
Reline::IOGate.deprep(otio)
raise e
rescue Exception
# Including Interrupt
line_editor.finalize
Reline::IOGate.deprep(otio)
raise
end

line_editor.finalize
Expand Down
2 changes: 1 addition & 1 deletion lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def set_signal_handlers
when 'EXIT'
exit
else
@old_trap.call
@old_trap.call if @old_trap.respond_to?(:call)
end
}
begin
Expand Down

0 comments on commit 50ed575

Please sign in to comment.