(items, entry, query)
| 328 | } |
| 329 | |
| 330 | function searchScore(items, entry, query) { |
| 331 | var needle = String(query || "").toLowerCase().trim() |
| 332 | var label = entry.label.toLowerCase() |
| 333 | var nameText = nameSearchText(entry) |
| 334 | var descriptionText = String(entry.description || "").toLowerCase() |
| 335 | var score = 80 |
| 336 | |
| 337 | if (label === needle) score = entry.parent === "root" ? 2 : 0 |
| 338 | // An installed app whose name contains the query as a whole word ("zen" |
| 339 | // for Zen Browser) beats exact-labeled menu entries like Install > Zen. |
| 340 | else if (entry.kind === "app" && label.split(/\s+/).indexOf(needle) >= 0) score = 0 |
| 341 | else if (label.indexOf(needle) === 0) score = 10 |
| 342 | else if (label.indexOf(needle) >= 0) score = 30 |
| 343 | else if (nameText.indexOf(needle) >= 0) score = 40 |
| 344 | else if (descriptionTextMatches(needle, descriptionText)) score = 60 |
| 345 | |
| 346 | if (entry.kind === "menu" || entry.kind === "link") score -= 2 |
| 347 | // App rows sort after all menu items, so they lose the tiebreak below to an |
| 348 | // equal match. Outrank those, but stay inside the tier so better ones win. |
| 349 | if (entry.kind === "app") score -= 5 |
| 350 | |
| 351 | return score * 1000 + depthFor(items, entry.id) * 25 + entry.order |
| 352 | } |
| 353 | |
| 354 | function displayRow(items, itemOrder, checkedResults, entry, detail, score, section) { |
| 355 | var target = entry.kind === "link" ? entry.target : entry.id |
nothing calls this directly
no test coverage detected