From 80f4398f1fed8d46d73cab8045005c02189b34fc Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 12:40:11 -0300 Subject: idioms #14, the rest: wire's has_cell_pixels (@hasField on a struct that always has the field) goes with its comptime branches, syntax's predicate ops are a stringToEnum switch, the public surfaces of sam_edit, locations, Names, Macro, selection_pipe, recent and builtins_json name their sets (OutOfMemory, Writer.Error), and std.fs.path and max_path_bytes are std.Io.Dir's Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/locations.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/locations.zig') diff --git a/src/locations.zig b/src/locations.zig index e8c31bf0..f6a0cf9c 100644 --- a/src/locations.zig +++ b/src/locations.zig @@ -51,7 +51,7 @@ pub fn freeRows(gpa: std.mem.Allocator, rows: []Row) void { /// A copy of `rows` and all they own, gpa's: rows are a blob (File.State /// `location_rows`), made again rather than written. -pub fn cloneRows(gpa: std.mem.Allocator, rows: []const Row) ![]Row { +pub fn cloneRows(gpa: std.mem.Allocator, rows: []const Row) error{OutOfMemory}![]Row { const out = try gpa.alloc(Row, rows.len); var made: usize = 0; errdefer { @@ -84,7 +84,7 @@ pub fn freeRowList(gpa: std.mem.Allocator, rows: *std.ArrayList(Row)) void { /// `row` onto a list being built, with copies of its own of the path and /// the colours it borrows. -pub fn appendRow(gpa: std.mem.Allocator, rows: *std.ArrayList(Row), row: Row) !void { +pub fn appendRow(gpa: std.mem.Allocator, rows: *std.ArrayList(Row), row: Row) error{OutOfMemory}!void { var owned = row; owned.path = try gpa.dupe(u8, row.path); errdefer gpa.free(owned.path); @@ -227,8 +227,8 @@ const Source = struct { path: []const u8, bytes: []const u8 }; /// A file's text as a look from `dir` finds it: an open pane's, unsaved /// edits and all, else the disk's. Null for a PDF or one not there. pub fn sourceText(p: *pardes.Pardes, arena: std.mem.Allocator, dir: []const u8, path: []const u8) ?Source { - if (std.ascii.eqlIgnoreCase(std.fs.path.extension(path), ".pdf")) return null; - const lexical = std.fs.path.resolvePosix(arena, &.{ dir, path }) catch return null; + if (std.ascii.eqlIgnoreCase(std.Io.Dir.path.extension(path), ".pdf")) return null; + const lexical = std.Io.Dir.path.resolvePosix(arena, &.{ dir, path }) catch return null; var pathbuf: [4096]u8 = undefined; const full = if (filesystem.resolve(p, path, dir, &pathbuf)) |resolved| resolved.path else lexical; for (p.panes) |slot| if (slot) |pane| { -- cgit v1.3