diff --git a/plugins/pomodoro b/plugins/pomodoro index b2ea820..bc05ad8 100755 --- a/plugins/pomodoro +++ b/plugins/pomodoro @@ -68,7 +68,7 @@ class EventLoop else timer.index = @timers.size @timers.push timer - heapify_up @timers.size - 1 + heapify_up timer.index end end @@ -126,7 +126,7 @@ private def dispatch_timers now = Time.new - while not @timers.empty? and @timers[0].when < now do + while not @timers.empty? and @timers[0].when <= now do @timers[0].callback.call remove_timer_at 0 end @@ -134,7 +134,7 @@ private def nearest_timeout return nil if @timers.empty? - timeout = @timers[0].when - Time.new + timeout = @timers[0].until if timeout < 0 then 0 else timeout end end