Skip to content

Commit

Permalink
Don't show repos more than once in results
Browse files Browse the repository at this point in the history
  • Loading branch information
lackac committed Jun 5, 2011
1 parent 2f74773 commit 216e96d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions ext/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ chrome.omnibox.onInputChanged.addListener(function(text, suggest) {
if (text == '') return;

currentRequest = complete(text, function(lines) {
lines = lines.split("\n");
topResult = null;
currentResults = [];

Expand Down Expand Up @@ -75,9 +74,20 @@ chrome.omnibox.onInputCancelled.addListener(function() {
function complete(query, callback) {
query = query.replace(/^\/|\/$/g, '').toLowerCase();
var url = DB + '/_design/repos/_list/complete/by_prefix' +
'?startkey=["' + query + '",{}]&endkey=["' + query + '"]&descending=true&limit=6&stale=ok';
'?startkey=["' + query + '",{}]&endkey=["' + query + '"]&descending=true&limit=10&stale=ok';

return $.get(url, callback);
return $.get(url, function(lines) {
lines = lines.split("\n");
var uniqLines = [], lookup = {};
lines.forEach(function(line) {
var match = line.match(/^\*?([^ ]+) /), id = match && match[1];
if (id && !lookup[id]) {
lookup[id] = true;
uniqLines.push(line);
}
});
callback(uniqLines);
});
}

function getUrl(path) {
Expand Down

0 comments on commit 216e96d

Please sign in to comment.