╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ search_thread.zig ────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
83 } else if (std.mem.startsWith(u8, term, assignee_prefix)) { 84 if (term.len > assignee_prefix.len) try assignees.append(aa, term[assignee_prefix.len..]); 85 } else try words.append(aa, term); 86 } 87 return .{ .labels = labels.items, .assignees = assignees.items, .words = try std.mem.join(aa, " ", words.items) }; 88 } 89 90 // `search` with its `prefix` terms replaced by one for `value`, put first 91 pub fn withFilter(aa: std.mem.Allocator, search: []const u8, prefix: []const u8, value: []const u8) ![]const u8 { 92 var terms: std.ArrayList([]const u8) = .empty; 93 try terms.append(aa, try std.mem.concat(aa, u8, &.{ prefix, value })); 94 var iter = std.mem.tokenizeAny(u8, search, &std.ascii.whitespace); 95 while (iter.next()) |term| { 96 if (!std.mem.startsWith(u8, term, prefix)) try terms.append(aa, term); 97 } 98 return std.mem.join(aa, " ", terms.items); 99 } 100 101 // the text a thread is indexed under, none once it is removed: the title and 102 // labels first, so the tokenizer's caps can only drop the tail of a long 103 // description. 104 fn text(aa: std.mem.Allocator, record: anytype) ![]const u8 { 105 if (record.removed) return ""; 106 return std.mem.concat(aa, u8, &.{ record.event.title, " ", record.event.labels, " ", record.event.description }); 107 } 108