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) {...@@ -4328,9 +4328,9 @@ function addDeclToSearchResults(decl, declIndex, modNames, item, list, stack) {
4328 // shallow path are preferable4328 // shallow path are preferable
4329 const path_depth = canonPath.declNames.length * 50;4329 const path_depth = canonPath.declNames.length * 50;
4330 // matching the start of a decl name is good4330 // 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;
4332 // being a perfect match is good4332 // 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);
4334 // matching the end of a decl name is good4334 // matching the end of a decl name is good
4335 const matches_the_end = decl_name.endsWith(term) ? -term.length * (1 - ignoreCase) : (decl_name.length - term.length) + 1;4335 const matches_the_end = decl_name.endsWith(term) ? -term.length * (1 - ignoreCase) : (decl_name.length - term.length) + 1;
4336 // explicitly penalizing scream case decls4336 // explicitly penalizing scream case decls
...@@ -4409,7 +4409,7 @@ function addDeclToSearchResults(decl, declIndex, modNames, item, list, stack) {...@@ -4409,7 +4409,7 @@ function addDeclToSearchResults(decl, declIndex, modNames, item, list, stack) {
44094409
4410 const href = navLink(canonPath.modNames, canonPath.declNames);4410 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>";
4413 }4413 }
4414 }4414 }
44154415
src/Autodoc.zig-2
...@@ -1630,8 +1630,6 @@ fn walkInstruction(...@@ -1630,8 +1630,6 @@ fn walkInstruction(
16301630
1631 self.exprs.items[bin_index] = .{ .builtin = .{ .name = @tagName(tags[inst_index]), .param = rhs_index } };1631 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});
1635 return DocData.WalkResult{1633 return DocData.WalkResult{
1636 .typeRef = lhs.expr,1634 .typeRef = lhs.expr,
1637 .expr = .{ .builtinIndex = bin_index },1635 .expr = .{ .builtinIndex = bin_index },