1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-15 04:15:46 +01:00

Bang on tests some more. Ameliorate some async completion issues.

--HG--
extra : rebase_source : 0f550b1650963e4010e447db2df7d6815627bae2
This commit is contained in:
Kris Maglione
2011-02-01 04:02:29 -05:00
parent e38f408b5d
commit a21db1858a
7 changed files with 174 additions and 107 deletions

View File

@@ -281,11 +281,16 @@ var Config = Module("config", ConfigBase, {
const { CompletionContext, bookmarkcache, bookmarks, completion } = modules;
const { document } = window;
var searchRunning = false; // only until Firefox fixes https://bugzilla.mozilla.org/show_bug.cgi?id=510589
var searchRunning = null; // only until Firefox fixes https://bugzilla.mozilla.org/show_bug.cgi?id=510589
completion.location = function location(context) {
if (!services.autoCompleteSearch)
return;
if (searchRunning) {
searchRunning.completions = searchRunning.completions;
searchRunning.cancel();
}
context.anchored = false;
context.compare = CompletionContext.Sort.unsorted;
context.filterFunc = null;
@@ -297,30 +302,27 @@ var Config = Module("config", ConfigBase, {
context.title = ["Smart Completions"];
context.cancel = function () {
if (searchRunning) {
this.incomplete = false;
if (searchRunning === this) {
services.autoCompleteSearch.stopSearch();
searchRunning = false;
searchRunning = null;
}
};
if (searchRunning)
services.autoCompleteSearch.stopSearch();
let timer = new Timer(50, 100, function (result) {
context.incomplete = result.searchResult >= result.RESULT_NOMATCH_ONGOING;
context.completions = [
{ url: result.getValueAt(i), title: result.getCommentAt(i), icon: result.getImageAt(i) }
for (i in util.range(0, result.matchCount))
];
});
services.autoCompleteSearch.startSearch(context.filter, "", context.result, {
onSearchResult: function onSearchResult(search, result) {
timer.tell(result);
if (result.searchResult <= result.RESULT_SUCCESS) {
searchRunning = false;
timer.flush();
}
}
if (result.searchResult <= result.RESULT_SUCCESS)
searchRunning = null;
context.incomplete = result.searchResult >= result.RESULT_NOMATCH_ONGOING;
context.completions = [
{ url: result.getValueAt(i), title: result.getCommentAt(i), icon: result.getImageAt(i) }
for (i in util.range(0, result.matchCount))
];
},
get onUpdateSearchResult() this.onSearchResult
});
searchRunning = true;
searchRunning = context;
};
completion.sidebar = function sidebar(context) {