mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 08:17:59 +01:00
prevent completion flickering by using a cache
This commit is contained in:
1
Donators
1
Donators
@@ -2,6 +2,7 @@
|
||||
<b>Note:</b> If you don't wish to appear on this list when making a donation, please tell me.
|
||||
|
||||
2008:
|
||||
* Ben Damm
|
||||
* Anton Kovalenko
|
||||
* Paulo Tanimoto
|
||||
* Paul Sobey
|
||||
|
||||
@@ -34,6 +34,8 @@ liberator.Completion = function () //{{{
|
||||
|
||||
// the completion substrings, used for showing the longest common match
|
||||
var substrings = [];
|
||||
var urlResultsCache = null;
|
||||
var urlCompletionCache = [];
|
||||
|
||||
// function uses smartcase
|
||||
// list = [ [['com1', 'com2'], 'text'], [['com3', 'com4'], 'text'] ]
|
||||
@@ -251,15 +253,20 @@ liberator.Completion = function () //{{{
|
||||
{
|
||||
var completionService = Components.classes["@mozilla.org/browser/global-history;2"].
|
||||
getService(Components.interfaces.nsIAutoCompleteSearch);
|
||||
completionService.startSearch(filter, "", null, {
|
||||
completionService.startSearch(filter, "", urlResultsCache, {
|
||||
onSearchResult: function (search, result) {
|
||||
//if (result.searchResult != result.RESULT_SUCCESS)
|
||||
// return;
|
||||
//liberator.log(result.searchResult);
|
||||
//var res = "";// + util.objectToString(result) + "\n---\n";
|
||||
//liberator.log(result.matchCount + " matches: " + result.searchResult);
|
||||
var comp = [];
|
||||
urlResultsCache = result;
|
||||
for (var i = 0; i < result.matchCount; i++)
|
||||
{
|
||||
comp.push([result.getValueAt(i), result.getCommentAt(i)]);
|
||||
}
|
||||
urlCompletionCache = comp;
|
||||
if (comp.length > 0 || result.searchResult == result.RESULT_SUCCESS)
|
||||
liberator.commandline.setCompletions(completions.concat(comp));
|
||||
}
|
||||
@@ -267,7 +274,7 @@ liberator.Completion = function () //{{{
|
||||
}
|
||||
}
|
||||
|
||||
return [start, completions];
|
||||
return [start, completions.concat(urlCompletionCache)];
|
||||
},
|
||||
|
||||
search: function (filter)
|
||||
|
||||
@@ -996,8 +996,10 @@ liberator.CommandLine = function () //{{{
|
||||
if (liberator.mode != liberator.modes.COMMAND_LINE)
|
||||
return;
|
||||
|
||||
// liberator.log(compl);
|
||||
|
||||
completions = compl;
|
||||
completionlist.show(compl, 10);
|
||||
completionlist.show(compl);
|
||||
completionIndex = -1;
|
||||
|
||||
var command = this.getCommand();
|
||||
|
||||
Reference in New Issue
Block a user