diff options
Diffstat (limited to 'src/look.zig')
| -rw-r--r-- | src/look.zig | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/look.zig b/src/look.zig index 22aa4882..8f5ed900 100644 --- a/src/look.zig +++ b/src/look.zig @@ -293,7 +293,7 @@ test "lookableLineSpan prefers the longest run, so a blank inside a path is one try tmp.dir.createDir(io, "subdir", .default_dir); var path: [4096]u8 = undefined; const len = try tmp.dir.realPathFile(io, name, &path); - const cwd = std.fs.path.dirname(path[0..len]).?; + const cwd = std.Io.Dir.path.dirname(path[0..len]).?; try std.testing.expectEqualDeep( @as(?Span, .{ .start = 0, .end = name.len }), lineSpan(null, name, cwd, &realbuf), @@ -633,7 +633,7 @@ pub fn runSearch(p: *Pardes, id: usize, pat_raw: []const u8, start: SearchStart, // relative to `dir`, like Find's rows — and `dir` IS this file's // own directory, so that is exactly its basename const loc: []const u8 = if (has_path) - std.fs.path.basename(pane.file.?.path) + std.Io.Dir.path.basename(pane.file.?.path) else std.fmt.bufPrint(&idbuf, config.pane_addr ++ "{d}", .{pane.serial}) catch unreachable; // `@p` and a u32: 12 bytes const cl: usize = @intCast(@max(0, pane.body.cur_row)); @@ -1217,9 +1217,7 @@ test "a zero column after a path is found, in every spelling a look takes" { fn missed(p: *Pardes, id: usize, comptime fmt: []const u8, args: anytype) void { p.look_missed = true; var said: [miss_path_cap + 64]u8 = undefined; - var w = std.Io.Writer.fixed(&said); - w.print(fmt, args) catch {}; // a longer miss is said cut at the buffer's end - const why = w.buffered(); + const why = std.fmt.bufPrint(&said, fmt, args) catch &said; // a longer miss is cut at the buffer's end var msg: [said.len + 8]u8 = undefined; // Shown on the pane; logged once, as the err below, not a msg too. p.fs.unlogged = true; @@ -1342,7 +1340,7 @@ fn lookCommit(p: *Pardes, id: usize, pane: *Pane, word: []const u8) bool { var buf: [4096]u8 = undefined; const dot_git = std.fmt.bufPrint(&buf, "{s}/.git", .{dir}) catch return false; if (exec.kindOf(dot_git) != null) break; - dir = std.fs.path.dirname(dir) orelse return false; + dir = std.Io.Dir.path.dirname(dir) orelse return false; } var line: [64]u8 = undefined; const dst = exec.execute(p, id, std.fmt.bufPrint(&line, "git show {s}", .{word}) catch return false) orelse return true; @@ -1417,7 +1415,7 @@ fn lookAddress(p: *Pardes, id: usize, path: []const u8, expr: []const u8) void { var cut: [miss_path_cap + "…".len]u8 = undefined; return missed(p, id, "{s} is no text to address", .{missText(subject, &cut)}); }; - if (!by_serial and path.len > 0 and (f.output != null or !std.mem.endsWith(u8, f.path, std.fs.path.basename(path)))) return; + if (!by_serial and path.len > 0 and (f.output != null or !std.mem.endsWith(u8, f.path, std.Io.Dir.path.basename(path)))) return; var a: Addr = .{ .text = f.content, .lim = null, .expr = expr }; // A miss names the file it was looked for in, and is that file's pane's. var cut: [miss_path_cap + "…".len]u8 = undefined; @@ -2049,18 +2047,18 @@ const DiffFixture = struct { errdefer f.tmp.cleanup(); if (repo) try f.tmp.dir.createDir(io, ".git", .default_dir); for (files) |file| { - if (std.fs.path.dirname(file[0])) |sub| try f.tmp.dir.createDirPath(io, sub); + if (std.Io.Dir.path.dirname(file[0])) |sub| try f.tmp.dir.createDirPath(io, sub); try f.tmp.dir.writeFile(io, .{ .sub_path = file[0], .data = file[1] }); } try f.tmp.dir.writeFile(io, .{ .sub_path = "change.diff", .data = diff_text }); const len = try f.tmp.dir.realPathFile(io, "change.diff", &f.dir_buf); - f.dir = std.fs.path.dirname(f.dir_buf[0..len]).?; + f.dir = std.Io.Dir.path.dirname(f.dir_buf[0..len]).?; } fn open(f: *DiffFixture, p: *Pardes, diff_text: []const u8) !*Pane { const pane = try p.setTestFile(diff_text); p.gpa.free(pane.file.?.path); - pane.file.?.path = try std.fs.path.join(p.gpa, &.{ f.dir, "change.diff" }); + pane.file.?.path = try std.Io.Dir.path.join(p.gpa, &.{ f.dir, "change.diff" }); return pane; } @@ -2348,7 +2346,7 @@ test "every entry point to Look takes one expansion: a diff line and a file:12:5 defer p.deinit(); const pane = try fx.open(p, case.text); p.gpa.free(pane.file.?.path); - pane.file.?.path = try std.fs.path.join(p.gpa, &.{ fx.dir, case.name }); + pane.file.?.path = try std.Io.Dir.path.join(p.gpa, &.{ fx.dir, case.name }); pane.tag_expanded = false; var frame = std.heap.ArenaAllocator.init(std.testing.allocator); defer frame.deinit(); @@ -2495,7 +2493,7 @@ test "Incl's directories find a name found nowhere else, <name> too; bare Incl l try std.testing.expectEqualStrings("/usr/include", p.incl.items[0]); const pane = try p.setTestFile("#include <pardes_incl_probe.h>\n"); p.gpa.free(pane.file.?.path); - pane.file.?.path = try std.fs.path.join(p.gpa, &.{ root, "src", "main.c" }); + pane.file.?.path = try std.Io.Dir.path.join(p.gpa, &.{ root, "src", "main.c" }); var line: [4200]u8 = undefined; try std.testing.expect(p.executeBuiltinLine(0, try std.fmt.bufPrint(&line, "Incl {s}/inc", .{root}))); for ([_][]const u8{ "pardes_incl_probe.h", "<pardes_incl_probe.h>" }) |word| { @@ -2531,7 +2529,7 @@ test "LookNext in a command pane walks its own file:line places, whoever walked defer p.deinit(); const doc = try p.setTestFile("x\n"); p.gpa.free(doc.file.?.path); - doc.file.?.path = try std.fs.path.join(p.gpa, &.{ dir, "main.c" }); + doc.file.?.path = try std.Io.Dir.path.join(p.gpa, &.{ dir, "main.c" }); while (p.nextEffect()) |_| {} const dst = exec.execute(p, 0, "make") orelse return error.NoCommandPane; while (p.nextEffect()) |_| {} |
