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