mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 07:27:58 +01:00
made autocompletions not hang the GUI for quick input
This commit is contained in:
@@ -76,6 +76,7 @@ const util = { //{{{
|
||||
}
|
||||
},
|
||||
|
||||
// TODO: class could have better variable names/documentation
|
||||
Timer: function Timer(minInterval, maxInterval, callback)
|
||||
{
|
||||
let timer = Components.classes["@mozilla.org/timer;1"]
|
||||
@@ -88,6 +89,7 @@ const util = { //{{{
|
||||
this.latest = 0;
|
||||
/* minInterval is the time between the completion of the command and the next firing. */
|
||||
this.doneAt = Date.now() + minInterval;
|
||||
|
||||
try
|
||||
{
|
||||
callback(this.arg);
|
||||
@@ -110,9 +112,10 @@ const util = { //{{{
|
||||
if (now > this.doneAt && this.doneAt > -1)
|
||||
timeout = 0;
|
||||
else if (this.latest)
|
||||
timeout = Math.min(minInterval, this.latest - now);
|
||||
timeout = minInterval;
|
||||
else
|
||||
this.latest = now + maxInterval;
|
||||
|
||||
timer.initWithCallback(this, Math.max(timeout, 0), timer.TYPE_ONE_SHOT);
|
||||
this.doneAt = -1;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user