diff options
author | Miran <narimiran@disroot.org> | 2020-04-16 20:22:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-16 20:22:32 +0200 |
commit | 06e0c75ba9cd46cbbb09deb91db6f746fb62a820 (patch) | |
tree | 967eab916fcb620bc9565c1cb91ef47a90dcacaa /tools/dochack | |
parent | 6914de0d8dfb14e4ebe0448c558466c9bb80d833 (diff) | |
download | Nim-06e0c75ba9cd46cbbb09deb91db6f746fb62a820.tar.gz |
make fuzzy search a bit less fuzzy (#13996) [backport:1.2]
Diffstat (limited to 'tools/dochack')
-rw-r--r-- | tools/dochack/dochack.nim | 2 | ||||
-rw-r--r-- | tools/dochack/fuzzysearch.nim | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/tools/dochack/dochack.nim b/tools/dochack/dochack.nim index 2f8465a63..4c4db4638 100644 --- a/tools/dochack/dochack.nim +++ b/tools/dochack/dochack.nim @@ -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: diff --git a/tools/dochack/fuzzysearch.nim b/tools/dochack/fuzzysearch.nim index 05f61bc11..fecbaf4f0 100644 --- a/tools/dochack/fuzzysearch.nim +++ b/tools/dochack/fuzzysearch.nim @@ -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), |