diff options
-rw-r--r-- | lib/search.js | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/search.js b/lib/search.js index 9fea92025..faa663c59 100644 --- a/lib/search.js +++ b/lib/search.js @@ -111,7 +111,6 @@ function filterWords (data, args, notArgs) { var words = data.words for (var i = 0, l = args.length; i < l; i ++) { if (words.indexOf(args[i]) === -1) { - //console.error("fail %j", [args[i], words]) return false } } @@ -134,7 +133,7 @@ function prettify (data, args) { // name, desc, author, keywords var longest = [] , spaces - , maxLen = [20, 80, 25] + , maxLen = [20, 60, 20] return Object.keys(data).map(function (d) { return data[d] }).map(function (data) { @@ -151,8 +150,13 @@ function prettify (data, args) { , (data.keywords || []).join(" ") ] l.forEach(function (s, i) { + var len = s.length longest[i] = Math.min(maxLen[i] || Infinity - ,Math.max(longest[i] || 0, s.length)) + ,Math.max(longest[i] || 0, len)) + if (len > longest[i]) { + l._undent = l._undent || [] + l._undent[i] = len - longest[i] + } l[i] = l[i].replace(/\s+/g, " ") }) return l @@ -161,7 +165,11 @@ function prettify (data, args) { spaces = spaces || longest.map(function (n) { return new Array(n + 2).join(" ") }) - return (s + spaces[i].substr(s.length)) + var len = s.length + if (line._undent && line._undent[i - 1]) { + len += line._undent[i - 1] - 1 + } + return s + spaces[i].substr(len) }).join(" ").substr(0, cols) }).sort(function (a, b) { return a === b ? 0 : a > b ? 1 : -1 @@ -174,7 +182,7 @@ function prettify (data, args) { }).join("\n") } -var colors = [36, 32, 33, 31, 35 ] +var colors = [31, 33, 32, 36, 34, 35 ] , cl = colors.length function addColorMarker (str, arg, i) { var m = i % cl + 1 |