mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
make fuzzy search a bit less fuzzy (#13996) [backport:1.2]
This commit is contained in:
@@ -303,7 +303,7 @@ proc dosearch(value: cstring): Element =
|
||||
matches.add((db[i], score))
|
||||
|
||||
matches.sort(proc(a, b: auto): int = b[1] - a[1])
|
||||
for i in 0 ..< min(matches.len, 19):
|
||||
for i in 0 ..< min(matches.len, 29):
|
||||
matches[i][0].innerHTML = matches[i][0].getAttribute("data-doc-search-tag")
|
||||
ul.add(tree("LI", cast[Element](matches[i][0])))
|
||||
if ul.len == 0:
|
||||
|
||||
@@ -132,6 +132,9 @@ proc fuzzyMatch*(pattern, str: cstring) : tuple[score: int, matched: bool] =
|
||||
|
||||
strIndex += 1
|
||||
|
||||
if patIndex == pattern.len and (strIndex == str.len or str[strIndex] notin Letters):
|
||||
score += 10
|
||||
|
||||
result = (
|
||||
score: max(0, score),
|
||||
matched: (score > 0),
|
||||
|
||||
Reference in New Issue
Block a user