diff options
| author | Phil Crosby | 2012-05-26 10:16:48 -0700 |
|---|---|---|
| committer | Phil Crosby | 2012-05-26 10:19:01 -0700 |
| commit | 61c4f2c8c1af82f1fccdfcb6af366c086419b3b7 (patch) | |
| tree | a1e9cbb1ec2d6a4e97e9d9da20bd1d5ed943b98e | |
| parent | bb22d36d0ef0d50de3fc28162e18b292eaa4bea6 (diff) | |
| download | vimium-61c4f2c8c1af82f1fccdfcb6af366c086419b3b7.tar.bz2 | |
Don't show a trailing slash in vomnibar history results. It makes the display cleaner.
| -rw-r--r-- | background_scripts/completion.js | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/background_scripts/completion.js b/background_scripts/completion.js index 60125628..19a71646 100644 --- a/background_scripts/completion.js +++ b/background_scripts/completion.js @@ -124,31 +124,37 @@ var completion = (function() { * processed. * * TODO(philc): It would be nice if this could be removed; it's confusing. - * */ + */ createUnrankedCompletion: function(type, item, action) { var url = item.url; - var parts = [type, url, item.title]; - var str = parts.join(" "); + var completionString = [type, url, item.title].join(" ") action = action || { functionName: "navigateToUrl", args: [url] }; + var displayUrl = this.stripTrailingSlash(url); function createLazyCompletion(query) { - var relevancy = url.length / fuzzyMatcher.calculateRelevancy(query, str) + var relevancy = url.length / fuzzyMatcher.calculateRelevancy(query, completionString); return new LazyCompletionResult(relevancy, function() { return { - html: renderFuzzy(query, createCompletionHtml.apply(null, parts)), - action: action, + html: renderFuzzy(query, createCompletionHtml(type, displayUrl, item.title)), + action: action }}); } - // add one more layer of indirection: For filtering, we only need the string to match. - // Only after we reduced the number of possible results, we call :bind on them to get - // an actual completion object + // Add one more layer of indirection: when filtering, we only need the string to match. + // Only after we reduced the number of possible results, we call :createLazyCompletion on them to get + // an actual completion object. return { - completionString: parts.join(" "), + completionString: completionString, createLazyCompletion: createLazyCompletion, } }, + stripTrailingSlash: function(url) { + if (url[url.length - 1] == "/") + url = url.substring(url, url.length - 1); + return url; + }, + processResults: function(query, results) { results = fuzzyMatcher.filter(query, results, function(match) { return match.completionString }, this.id); |
