1
0
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:
Martin Stubenschrott
2008-11-08 15:45:05 +00:00
parent 3e48c58ab3
commit eac34847e5
3 changed files with 15 additions and 1 deletions

View File

@@ -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;
};