diff --git a/content/events.js b/content/events.js index c4da4aca..985cefe0 100644 --- a/content/events.js +++ b/content/events.js @@ -286,6 +286,7 @@ liberator.Events = function () //{{{ ////////////////////// PRIVATE SECTION ///////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ + var replayingMacro; var inputBufferLength = 0; // count the number of keys in v.input.buffer (can be different from v.input.buffer.length) var skipMap = false; // while feeding the keys (stored in v.input.buffer | no map found) - ignore mappings @@ -780,7 +781,6 @@ liberator.Events = function () //{{{ if (macros.get(lastMacro)) { - liberator.modes.isReplaying = true; // make sure the page is stopped before starting to play the macro try { @@ -789,8 +789,9 @@ liberator.Events = function () //{{{ catch (e) {} liberator.buffer.loaded = 1; // even if not a full page load, assume it did load correctly before starting the macro + replayingMacro = true; res = liberator.events.feedkeys(macros.get(lastMacro), true); // true -> noremap - liberator.modes.isReplaying = false; + replayingMacro = false; } else { @@ -835,6 +836,7 @@ liberator.Events = function () //{{{ var view = window.document.defaultView; var escapeKey = false; // \ to escape some special keys var wasReplaying = liberator.modes.isReplaying; + liberator.modes.isReplaying = true; noremap = !!noremap; @@ -894,17 +896,15 @@ liberator.Events = function () //{{{ evt.noremap = noremap; evt.isMacro = true; elem.dispatchEvent(evt); + if (!liberator.modes.isReplaying) + break; // stop feeding keys if page loading failed - if (wasReplaying) - { - if (!liberator.modes.isReplaying) - break; - if (!waitForPageLoaded()) - break; - } + if (replayingMacro && !waitForPageLoaded()) + break; // else // a short break between keys often helps // liberator.sleep(50); } + liberator.modes.isReplaying = wasReplaying; return i == keys.length; }, @@ -1333,7 +1333,7 @@ liberator.Events = function () //{{{ liberator.input.pendingArgMap = null; // v.input.pendingArgMap is still 'true' also for new feeded keys if (key != "" && key != "") { - if (liberator.modes.isReplaying && !waitForPageLoaded()) + if (replayingMacro && !waitForPageLoaded()) return true; tmp.execute(null, liberator.input.count, key); @@ -1376,7 +1376,7 @@ liberator.Events = function () //{{{ liberator.input.buffer = ""; inputBufferLength = 0; - if (liberator.modes.isReplaying && !waitForPageLoaded()) + if (replayingMacro && !waitForPageLoaded()) return true; var ret = map.execute(null, liberator.input.count); diff --git a/content/ui.js b/content/ui.js index 54fe93a4..71c6707c 100644 --- a/content/ui.js +++ b/content/ui.js @@ -108,8 +108,10 @@ liberator.CommandLine = function () //{{{ var statusTimer = new liberator.util.Timer(5, 100, function () liberator.statusline.updateProgress("match " + (completionIndex + 1) + " of " + completions.length)); var autocompleteTimer = new liberator.util.Timer(201, 300, function (command) { - let res = liberator.completion.ex(command); - liberator.commandline.setCompletions(res[1], res[0]); + if (liberator.modes.isReplaying) + return; + let [start, compl] = liberator.completion.ex(command); + liberator.commandline.setCompletions(compl, start); }); // the containing box for the promptWidget and commandWidget @@ -574,10 +576,7 @@ liberator.CommandLine = function () //{{{ if (/\s/.test(cmd) && liberator.options.get("wildoptions").has("auto") >= 0 && extendedMode == liberator.modes.EX) - { - var [start, compl] = liberator.completion.ex(cmd); - this.setCompletions(compl, start); - } + autocompleteTimer.tell(cmd); }, // normally used when pressing esc, does not execute a command @@ -1175,7 +1174,8 @@ liberator.CommandLine = function () //{{{ completions = compl; completionList.selectItem(completionIndex); - completionList.show(); + if (liberator.options.get("wildoptions").has("auto")) + completionList.show(); var command = this.getCommand(); completionPrefix = command.substring(0, commandWidget.selectionStart); diff --git a/content/util.js b/content/util.js index fec8d642..fae2dba1 100644 --- a/content/util.js +++ b/content/util.js @@ -40,8 +40,14 @@ liberator.util = { //{{{ this.latest = 0; /* minInterval is the time between the completion of the command and the next firing. */ this.doneAt = Date.now() + minInterval; - callback(this.arg); - this.doneAt = Date.now() + minInterval; + try + { + callback(this.arg); + } + finally + { + this.doneAt = Date.now() + minInterval; + } } this.tell = function (arg) {