From e4680bfd2ef460a288a5765e75a340d13bb5bf77 Mon Sep 17 00:00:00 2001 From: Martin Stubenschrott Date: Wed, 18 Jun 2008 10:55:10 +0000 Subject: [PATCH] prevent completion flickering by using a cache --- Donators | 1 + content/completion.js | 11 +++++++++-- content/ui.js | 4 +++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Donators b/Donators index d784f962..81c110b7 100644 --- a/Donators +++ b/Donators @@ -2,6 +2,7 @@ Note: 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 diff --git a/content/completion.js b/content/completion.js index 8a2e7128..734d53be 100644 --- a/content/completion.js +++ b/content/completion.js @@ -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) diff --git a/content/ui.js b/content/ui.js index e529159a..fbdb1c13 100644 --- a/content/ui.js +++ b/content/ui.js @@ -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();