authorgravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2023-07-01 17:38:18+02:00
committergravatar for kappaloris@gmail.comLoris Cro <kappaloris@gmail.com> 2023-07-01 17:38:18+02:00
log97a1b046eac01c1a5bc6089339ff739bbc384ab0
tree78b9d1deb3e2fc7d0a801a2e1fb682e720259afc
parent35a8e8a06c0cb0a5a0c6ddcca3b70be05dc4d035

autodoc: fix scoring bug when matching full decl name


2 files changed, 3 insertions(+), 5 deletions(-)

lib/docs/main.js+3-3
......@@ -4328,9 +4328,9 @@ function addDeclToSearchResults(decl, declIndex, modNames, item, list, stack) {
43284328 // shallow path are preferable
43294329 const path_depth = canonPath.declNames.length * 50;
43304330 // matching the start of a decl name is good
4331 const match_from_start = decl_name.startsWith(term) ? -term.length * (1 -ignoreCase) : (decl_name.length - term.length) + 1;
4331 const match_from_start = decl_name.startsWith(term) ? -term.length * (2 -ignoreCase) : (decl_name.length - term.length) + 1;
43324332 // being a perfect match is good
4333 const is_full_match = (list == result.full) ? -decl_name.length * (2 - ignoreCase) : decl_name.length - term.length;
4333 const is_full_match = (decl_name === term) ? -decl_name.length * (1 - ignoreCase) : Math.abs(decl_name.length - term.length);
43344334 // matching the end of a decl name is good
43354335 const matches_the_end = decl_name.endsWith(term) ? -term.length * (1 - ignoreCase) : (decl_name.length - term.length) + 1;
43364336 // explicitly penalizing scream case decls
......@@ -4409,7 +4409,7 @@ function addDeclToSearchResults(decl, declIndex, modNames, item, list, stack) {
44094409
44104410 const href = navLink(canonPath.modNames, canonPath.declNames);
44114411
4412 matchedItemsHTML += "<li><a href=\"" + href + "\">" + text + "</a></li>";
4412 matchedItemsHTML += "<li><a href=\"" + href + "\">" + text + "</a></li>";
44134413 }
44144414 }
44154415
src/Autodoc.zig-2
......@@ -1630,8 +1630,6 @@ fn walkInstruction(
16301630
16311631 self.exprs.items[bin_index] = .{ .builtin = .{ .name = @tagName(tags[inst_index]), .param = rhs_index } };
16321632
1633 std.debug.print("lhs: {any}\n\n", .{lhs});
1634 std.debug.print("lhs typeref: {any}\n\n", .{lhs.typeRef});
16351633 return DocData.WalkResult{
16361634 .typeRef = lhs.expr,
16371635 .expr = .{ .builtinIndex = bin_index },