mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-28 14:55:54 +01:00
Revert "fixed :open completions for slow computers. We now yield"
This reverts commit b32cfe76ff5f5a22e868eb8ab97191b12561e16e.
This commit is contained in:
@@ -528,9 +528,7 @@ CompletionContext.prototype = {
|
|||||||
|
|
||||||
cancelAll: function ()
|
cancelAll: function ()
|
||||||
{
|
{
|
||||||
// Kris: contextList gives undefined. And why do we have contexts and contextList?
|
for (let [,context] in Iterator(this.contextList))
|
||||||
// I am not too much of a fan of a huge API for classes
|
|
||||||
for (let [,context] in Iterator(this.top.contexts))
|
|
||||||
{
|
{
|
||||||
if (context.cancel)
|
if (context.cancel)
|
||||||
context.cancel();
|
context.cancel();
|
||||||
@@ -1578,7 +1576,6 @@ function Completion() //{{{
|
|||||||
context.filterFunc = null;
|
context.filterFunc = null;
|
||||||
context.cancel = function () services.get("autoCompleteSearch").stopSearch();
|
context.cancel = function () services.get("autoCompleteSearch").stopSearch();
|
||||||
context.compare = null;
|
context.compare = null;
|
||||||
// TODO: shouldn't this timer be deleted by context.cancel?
|
|
||||||
let timer = new Timer(50, 100, function (result) {
|
let timer = new Timer(50, 100, function (result) {
|
||||||
context.incomplete = result.searchResult >= result.RESULT_NOMATCH_ONGOING;
|
context.incomplete = result.searchResult >= result.RESULT_NOMATCH_ONGOING;
|
||||||
context.completions = [
|
context.completions = [
|
||||||
@@ -1586,28 +1583,16 @@ function Completion() //{{{
|
|||||||
for (i in util.range(0, result.matchCount))
|
for (i in util.range(0, result.matchCount))
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
context.generate = function () {
|
services.get("autoCompleteSearch").stopSearch();
|
||||||
let minItems = context.minItems || 1;
|
services.get("autoCompleteSearch").startSearch(context.filter, "", context.result, {
|
||||||
services.get("autoCompleteSearch").stopSearch();
|
onSearchResult: function onSearchResult(search, result)
|
||||||
services.get("autoCompleteSearch").startSearch(context.filter, "", context.result, {
|
{
|
||||||
onSearchResult: function (search, result)
|
context.result = result;
|
||||||
{
|
timer.tell(result);
|
||||||
context.result = result;
|
if (result.searchResult <= result.RESULT_SUCCESS)
|
||||||
timer.tell(result);
|
timer.flush();
|
||||||
if (result.searchResult <= result.RESULT_SUCCESS)
|
}
|
||||||
timer.flush();
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let end = Date.now() + 5000;
|
|
||||||
while (context.incomplete && context.completions.length < minItems && Date.now() < end)
|
|
||||||
liberator.threadYield(false, true);
|
|
||||||
|
|
||||||
// context.message = "More results..."; // very very strange, if I enable this line, completions don't work;
|
|
||||||
services.get("autoCompleteSearch").stopSearch();
|
|
||||||
|
|
||||||
return context.completions;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
macro: function macro(context)
|
macro: function macro(context)
|
||||||
|
|||||||
@@ -1362,7 +1362,6 @@ const liberator = (function () //{{{
|
|||||||
callback.call(self);
|
callback.call(self);
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: interruptable not used?
|
|
||||||
threadYield: function (flush, interruptable)
|
threadYield: function (flush, interruptable)
|
||||||
{
|
{
|
||||||
let mainThread = services.get("threadManager").mainThread;
|
let mainThread = services.get("threadManager").mainThread;
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ function CommandLine() //{{{
|
|||||||
else
|
else
|
||||||
idx = this.selected + 1;
|
idx = this.selected + 1;
|
||||||
break;
|
break;
|
||||||
case this.RESET: // TODO: never used for now
|
case this.RESET:
|
||||||
idx = null;
|
idx = null;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -386,37 +386,22 @@ function CommandLine() //{{{
|
|||||||
tab: function tab(reverse)
|
tab: function tab(reverse)
|
||||||
{
|
{
|
||||||
autocompleteTimer.flush();
|
autocompleteTimer.flush();
|
||||||
|
|
||||||
// Check if we need to run the completer.
|
// Check if we need to run the completer.
|
||||||
let numElementsNeeded;
|
|
||||||
if (this.selected == null)
|
|
||||||
numElementsNeeded = reverse ? 100000 : 1; // better way to specify give me all items than setting to a very large number?
|
|
||||||
else
|
|
||||||
numElementsNeeded = reverse ? this.selected : this.selected + 2; // this.selected is zero-based
|
|
||||||
|
|
||||||
if (this.context.waitingForTab || this.wildIndex == -1)
|
if (this.context.waitingForTab || this.wildIndex == -1)
|
||||||
{
|
|
||||||
this.complete(true, true);
|
this.complete(true, true);
|
||||||
}
|
|
||||||
else if (this.context.incomplete && numElementsNeeded > this.items.length)
|
|
||||||
{
|
|
||||||
for (let [, context] in Iterator(this.context.contexts))
|
|
||||||
{
|
|
||||||
if (context.incomplete && context.generate)
|
|
||||||
{
|
|
||||||
// regenerate twice as many items as needed, as regenerating
|
|
||||||
// to often looks visually bad
|
|
||||||
context.minItems = numElementsNeeded * 2; // TODO: document minItems, or find a better way
|
|
||||||
context.regenerate = true;
|
|
||||||
context._generate(); // HACK
|
|
||||||
}
|
|
||||||
if (this.items.length >= numElementsNeeded)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.items.length == 0)
|
// Would prefer to only do this check when no completion
|
||||||
return liberator.beep();
|
// is available, but there are complications.
|
||||||
|
if (this.items.length == 0 || this.context.incomplete)
|
||||||
|
{
|
||||||
|
// No items. Wait for any unfinished completers.
|
||||||
|
let end = Date.now() + 5000;
|
||||||
|
while (this.context.incomplete && /* this.items.length == 0 && */ Date.now() < end)
|
||||||
|
liberator.threadYield(true, true);
|
||||||
|
|
||||||
|
if (this.items.length == 0)
|
||||||
|
return liberator.beep();
|
||||||
|
}
|
||||||
|
|
||||||
switch (this.wildtype.replace(/.*:/, ""))
|
switch (this.wildtype.replace(/.*:/, ""))
|
||||||
{
|
{
|
||||||
@@ -1619,9 +1604,11 @@ function CommandLine() //{{{
|
|||||||
{
|
{
|
||||||
autocompleteTimer.reset();
|
autocompleteTimer.reset();
|
||||||
|
|
||||||
|
// liberator.dump("Resetting completions...");
|
||||||
if (completions)
|
if (completions)
|
||||||
{
|
{
|
||||||
completions.context.cancelAll();
|
completions.context.cancelAll();
|
||||||
|
|
||||||
completions.wildIndex = -1;
|
completions.wildIndex = -1;
|
||||||
completions.previewClear();
|
completions.previewClear();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user