Skip to content
This repository was archived by the owner on Mar 12, 2023. It is now read-only.

Commit 4ad96ec

Browse files
committed
Fix redundant resizing dispatch
1 parent 0625e28 commit 4ad96ec

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

lib/ruby_jard/repl_interceptor.rb

+1-5
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,7 @@ def stop
7575
end
7676

7777
def dispatch_command(command)
78-
if interceptable?
79-
@input_writer.write("#{RubyJard::ReplManager::COMMAND_ESCAPE_SEQUENCE}#{command}\n")
80-
else
81-
RubyJard::ControlFlow.dispatch(command.to_sym)
82-
end
78+
@input_writer.write("#{RubyJard::ReplManager::COMMAND_ESCAPE_SEQUENCE}#{command}\n")
8379
end
8480

8581
def feed_output(content)

lib/ruby_jard/repl_manager.rb

+13-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def repl(current_binding)
3030
set_console_raw!
3131
unless @interceptor.interceptable?
3232
@console.output.puts '*Warning*: Key bindings are disabled! '\
33-
'There maybe a gem or a module touching Readline whose Jard depends on.'
33+
'There maybe something touching Jard\'s Readline depedency'
3434
end
3535

3636
pry_proxy.repl(current_binding)
@@ -58,7 +58,7 @@ def pry_proxy
5858
after_handle_line: proc {
5959
set_console_raw!
6060
@state.ready!
61-
@interceptor.dispatch_command('list') if @resizing && !@resizing_dispatched
61+
dispatch_resize! if @resizing && !@resizing_dispatched
6262
},
6363
before_pager: proc {
6464
@state.processing!
@@ -79,12 +79,19 @@ def start_resizing
7979

8080
@resizing = true
8181
@resizing_output_mark = @console.stdout_storage.length
82-
if @state.processing?
83-
@resizing_dispatched = false
84-
else
82+
@resizing_dispatched = false
83+
unless @state.processing?
8584
@resizing_readline_buffer = @pry_proxy&.line_buffer
85+
dispatch_resize!
86+
end
87+
end
88+
89+
def dispatch_resize!
90+
@resizing_dispatched = true
91+
if @interceptor.interceptable?
8692
@interceptor.dispatch_command('list')
87-
@resizing_dispatched = true
93+
else
94+
RubyJard::ControlFlow.dispatch(:list)
8895
end
8996
end
9097

0 commit comments

Comments
 (0)