diff --git a/lib/reline/io/ansi.rb b/lib/reline/io/ansi.rb index 30a89bc471..a730a953f7 100644 --- a/lib/reline/io/ansi.rb +++ b/lib/reline/io/ansi.rb @@ -347,6 +347,13 @@ def clear_screen def set_winch_handler(&handler) @old_winch_handler = Signal.trap('WINCH', &handler) + @old_cont_handler = Signal.trap('CONT') do + @input.raw!(intr: true) if @input.tty? + # Rerender the screen. Note that screen size might be changed while suspended. + handler.call + end + rescue ArgumentError + # Signal.trap may raise an ArgumentError if the platform doesn't support the signal. end def prep @@ -360,5 +367,6 @@ def deprep(otio) # Disable bracketed paste @output.write "\e[?2004l" if Reline.core.config.enable_bracketed_paste && both_tty? Signal.trap('WINCH', @old_winch_handler) if @old_winch_handler + Signal.trap('CONT', @old_cont_handler) if @old_cont_handler end end diff --git a/test/reline/yamatanooroti/test_rendering.rb b/test/reline/yamatanooroti/test_rendering.rb index f119d686cd..3722a28620 100644 --- a/test/reline/yamatanooroti/test_rendering.rb +++ b/test/reline/yamatanooroti/test_rendering.rb @@ -1840,6 +1840,25 @@ def test_thread_safe EOC end + def test_stop_continue + pidfile = Tempfile.create('pidfile') + rubyfile = Tempfile.create('rubyfile') + rubyfile.write <<~RUBY + File.write(#{pidfile.path.inspect}, Process.pid) + p Reline.readmultiline('>'){false} + RUBY + rubyfile.close + start_terminal(40, 50, ['bash']) + write "ruby -I#{@pwd}/lib -rreline #{rubyfile.path}\n" + write "abc\ndef\nhi" + pid = pidfile.tap(&:rewind).read.to_i + Process.kill(:STOP, pid) unless pid.zero? + write "fg\n" + write "\ebg" + close + assert_include result.join("\n"), ">abc\n>def\n>ghi\n" + end + def write_inputrc(content) File.open(@inputrc_file, 'w') do |f| f.write content