1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 22:37:58 +01:00

Fix tab-completion bugs

This commit is contained in:
Kris Maglione
2009-01-08 20:55:45 -05:00
parent 48d8b7cacd
commit 6534a0c665

View File

@@ -384,37 +384,41 @@ function CommandLine() //{{{
if (idx == -2) if (idx == -2)
list = list.slice().reverse(); list = list.slice().reverse();
let n = 0; let n = 0;
for (let [,context] in Iterator(list)) try
{ {
function done() !(idx >= n + context.items.length || idx == -2 && !context.items.length); this.waiting = true;
while (context.incomplete && !done()) for (let [,context] in Iterator(list))
{ {
// threadYield(true, true) would be better, but it does not return on my function done() !(idx >= n + context.items.length || idx == -2 && !context.items.length);
// machine until all awesomebar completions were reported, making while (context.incomplete && !done())
// :open foo<tab> nearly unusable, if the first 2 foo-completions would // threadYield(true, true) would be better, but it does not return on my
// be there fast, but it takes up to 20 sec to find more foo-completions // machine until all awesomebar completions were reported, making
// // :open foo<tab> nearly unusable, if the first 2 foo-completions would
// The strange thing is, I tested the 2009-01-07 nightly at work in Windows // be there fast, but it takes up to 20 sec to find more foo-completions
// and it seemed to work perfectly there. Will have to see if it's a //
// hardware (dual core there, vs. P4 at home) issue or an OS issue. // The strange thing is, I tested the 2009-01-07 nightly at work in Windows
// // and it seemed to work perfectly there. Will have to see if it's a
// While I *really* prefer this solution over my hack // hardware (dual core there, vs. P4 at home) issue or an OS issue.
// when it works, we can't have a nearly-defect :open //
// prompt when releasing vimp 2.0, even not just on certain // While I *really* prefer this solution over my hack
// computers, as :open is probably the most often used ex-command // when it works, we can't have a nearly-defect :open
// in vimperator // prompt when releasing vimp 2.0, even not just on certain
// // computers, as :open is probably the most often used ex-command
// liberator.threadYield(false, true); is just a temporary measure as // in vimperator
// it has other problems (hitting tab often in a row), until we find the //
// source of the problem (which we hopefully do, as I really don't want to // liberator.threadYield(false, true); is just a temporary measure as
// have to revert to my hack when better solutions exist) // it has other problems (hitting tab often in a row), until we find the
liberator.dump("before yielding"); // source of the problem (which we hopefully do, as I really don't want to
liberator.threadYield(false, true); // have to revert to my hack when better solutions exist)
liberator.dump("after yielding"); liberator.threadYield(false, true);
if (done())
break;
n += context.items.length;
} }
if (done()) }
break; finally
n += context.items.length; {
this.waiting = false;
} }
// See previous FIXME. This will break if new items in // See previous FIXME. This will break if new items in
@@ -429,6 +433,8 @@ function CommandLine() //{{{
this.itemList.selectItem(idx); this.itemList.selectItem(idx);
}, },
ntab: 0,
tab: function tab(reverse) tab: function tab(reverse)
{ {
autocompleteTimer.flush(); autocompleteTimer.flush();
@@ -436,34 +442,41 @@ function CommandLine() //{{{
if (this.context.waitingForTab || this.wildIndex == -1) if (this.context.waitingForTab || this.wildIndex == -1)
this.complete(true, true); this.complete(true, true);
switch (this.wildtype.replace(/.*:/, "")) this.ntab++;
if (this.waiting)
return;
while (this.ntab--)
{ {
case "": switch (this.wildtype.replace(/.*:/, ""))
this.select(0); {
break; case "":
case "longest": this.select(0);
if (this.items.length > 1)
{
if (this.substring && this.substring != this.completion)
this.completion = this.substring;
break; break;
} case "longest":
// Fallthrough if (this.items.length > 1)
case "full": {
this.select(reverse ? this.UP : this.DOWN) if (this.substring && this.substring != this.completion)
break; this.completion = this.substring;
break;
}
// Fallthrough
case "full":
this.select(reverse ? this.UP : this.DOWN)
break;
}
if (this.type.list)
completionList.show();
this.wildIndex = Math.max(0, Math.min(this.wildtypes.length - 1, this.wildIndex + 1));
this.preview();
statusTimer.tell();
} }
if (this.items.length == 0) if (this.items.length == 0)
return void liberator.beep(); liberator.beep();
if (this.type.list)
completionList.show();
this.wildIndex = Math.max(0, Math.min(this.wildtypes.length - 1, this.wildIndex + 1));
this.preview();
statusTimer.tell();
} }
} }