Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (37 sloc) 1.17 KB
diff --git a/lib/plugins/defaults/auto_reload.rb b/lib/plugins/defaults/auto_reload.rb
index ae13bbe..6f373e9 100644
--- a/lib/plugins/defaults/auto_reload.rb
+++ b/lib/plugins/defaults/auto_reload.rb
@@ -1,13 +1,31 @@
# -*- coding: utf-8 -*-
module Termtter::Client
- add_task(:name => :auto_reload, :interval => config.update_interval, :after => config.update_interval) do
+ last_line_buffer = nil
+ input_checker_interval = config.update_interval / 10
+
+ add_task(:name => :input_checker, :interval => input_checker_interval, :after => config.update_interval) do
+ last_line_buffer = Readline.line_buffer
+ end
+
+ reload_proc = lambda do
begin
- call_commands('reload -r')
+ if last_line_buffer == Readline.line_buffer
+ call_commands('reload -r')
+ else
+ add_task(:name => :re_auto_reload, :after => input_checker_interval, &reload_proc)
+ end
rescue Exception => e
handle_error(e)
end
end
+ add_task(
+ :name => :auto_reload,
+ :interval => config.update_interval,
+ :after => config.update_interval,
+ &reload_proc
+ )
+
register_hook(
:name => :auto_reload_init,
:point => :initialize,