~gpanders/wk

5ce1b9c4ea4e17245abfd85792d235aa3629aee2 — Greg Anders 9 months ago 735c5a5
Find zettels by ID + title

This allows commands to be chained, i.e.

  zet open $(zet tag tagname)
1 files changed, 8 insertions(+), 0 deletions(-)

M src/zettel.zig
M src/zettel.zig => src/zettel.zig +8 -0
@@ 95,6 95,14 @@ pub fn findZettel(zettels: []const Zettel, keyword: []const u8) ?Zettel {
                return zet;
            }
        }

        // Also try id + title
        if (std.mem.startsWith(u8, keyword, zet.id) and
            keyword.len > ID_LENGTH + 1 and keyword[ID_LENGTH] == ' ' and
            std.ascii.eqlIgnoreCase(keyword[ID_LENGTH + 1 ..], zet.title))
        {
            return zet;
        }
    }

    return null;