diff options
Diffstat (limited to 'core/look.zig')
| -rw-r--r-- | core/look.zig | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/core/look.zig b/core/look.zig index cc3e750f..21043250 100644 --- a/core/look.zig +++ b/core/look.zig @@ -390,7 +390,8 @@ pub fn submitSearch(p: *Pardes, id: usize) void { p.registers.put(p.gpa, '/', a.pat, 0, 1, true) catch |err| return p.reportError(.at(id), "search", err); p.registers.last_search = '/'; } - return if (panes.promptTarget(p, pane)) |t| normal.applySelRegex(p, pane, t, a.pat, a.mode); + if (panes.promptTarget(p, pane)) |t| _ = normal.applySelRegex(p, pane, t, a.pat, a.mode); + return; } const armed = pane.promptText() orelse return; const slash = std.mem.indexOfScalar(u8, armed, '/') orelse return; @@ -1537,7 +1538,6 @@ fn walk(p: *Pardes, from: usize, path: []const u8, at: Spot) Landed { } const into = if (reads) from else Trail.readerOf(p, src) orelse { const free = openNew(p, from, path, at, .reader) orelse return .none; - p.panes[free].?.trail = Trail.reader(src.serial, path, at); return .{ .opened = free }; }; _ = Trail.step(p, into, path, at) catch |err| { @@ -1565,6 +1565,9 @@ fn openNew(p: *Pardes, from: usize, path: []const u8, at: Spot, kind: layout.New return null; }; nt.body.cur_col = columnOn(nt, nt.body.cur_row, at.col); + // A reader's walk (its owner's word, its place) is in its tag before + // it is placed: the rows it is given are for the tag it shows. + if (kind == .reader) nt.trail = Trail.reader(p.panes[from].?.serial, path, at); const failures = p.fs.failures; layout.placeNew(p, from, from, free, kind); // Refused a place: that is the look's one failure, not a miss of its @@ -2020,6 +2023,8 @@ test "a Look that opens a file in a pane of its own puts its line half the body' const dir = buf[0..try tmp.dir.realPath(io, &buf)]; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 60, .rows = 40 }); defer p.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + p.settings.jumps = .@"new-pane"; p.settings.wrap = true; _ = try p.setTestFile("x\n"); var line: [4200]u8 = undefined; @@ -2213,6 +2218,8 @@ test "Look copies its operand before releasing pointer selection storage" { test "a Look whose column is past its line's end lands at the end, however big; a line past the file's is a miss" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12 }); defer p.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + p.settings.jumps = .@"new-pane"; const pane = try p.setTestFile("alpha\n\tbeta\n"); // Up to 2026-11-23 a column past i32 panicked the session (`@intCast` // in focusPaneLine): any text a B3 or Look takes, a server's row. @@ -2305,6 +2312,8 @@ test "Look on each kind of diff line opens the new file at the line it names" { defer fx.tmp.cleanup(); const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 30 }); defer p.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + p.settings.jumps = .@"new-pane"; const pane = try fx.open(p, diff_text); DiffFixture.click(p, pane, 4); // @@: the hunk's first new line @@ -2357,6 +2366,8 @@ test "Look on plain diff -u output: names as written, timestamps cut, next to th defer fx.tmp.cleanup(); const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 30 }); defer p.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + p.settings.jumps = .@"new-pane"; const pane = try fx.open(p, diff_text); DiffFixture.click(p, pane, 4); try expectAt(p, "/new/x.zig", 2); @@ -2384,6 +2395,8 @@ test "Look on a diff: headers and a hunk line's prefix are the whole line, hover defer fx.tmp.cleanup(); const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 30 }); defer p.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + p.settings.jumps = .@"new-pane"; const pane = try fx.open(p, diff_text); pane.tag_expanded = false; // `word`: what the pointer there expands to when it is not the whole @@ -2542,6 +2555,8 @@ test "every entry point to Look takes one expansion: a diff line and a file:12:5 for (cases) |case| { const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 30 }); defer p.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + p.settings.jumps = .@"new-pane"; const pane = try fx.open(p, case.text); p.gpa.free(pane.file.?.path); pane.file.?.path = try std.Io.Dir.path.join(p.gpa, &.{ fx.dir, case.name }); @@ -2686,6 +2701,8 @@ test "Incl's directories find a name found nowhere else, <name> too; bare Incl l const root = dir_buf[0..try tmp.dir.realPath(std.testing.io, &dir_buf)]; const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 30 }); defer p.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + p.settings.jumps = .@"new-pane"; // C's two by default. try std.testing.expectEqualStrings("/usr/include", p.incl.items[0]); const pane = try p.setTestFile("#include <pardes_incl_probe.h>\n"); @@ -2702,7 +2719,7 @@ test "Incl's directories find a name found nowhere else, <name> too; bare Incl l } // Bare, it lists them. try std.testing.expect(p.executeBuiltinLine(0, "Incl")); - try std.testing.expect(std.mem.indexOf(u8, pane.msg[0..pane.msg_len], "/inc") != null); + try std.testing.expect(std.mem.indexOf(u8, p.messages.saidBy(pane), "/inc") != null); // A dump keeps them. try pardes.dump.dumpState(p); const restored = try pardes.dump.restore(p, p.dump_out.?, "/tmp/pardes.dump.zon"); @@ -2787,6 +2804,8 @@ test "Look on a diff under each git prefix opens the repository's file, and a re defer fx.tmp.cleanup(); const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 30 }); defer p.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + p.settings.jumps = .@"new-pane"; const pane = try fx.open(p, c.text); DiffFixture.click(p, pane, 6); // `two`, a context line: new line 2 try std.testing.expect(!p.look_missed); @@ -2820,6 +2839,8 @@ test "Look on a diff line is the look of the address it names, selected by hand: for (0..2) |way| { const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 30 }); defer p.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + p.settings.jumps = .@"new-pane"; const pane = try cache.open(p, patch); // The checkout's file, opened by a look from the diff pane. lookAt(p, 0, cargo); @@ -2840,7 +2861,7 @@ test "Look on a diff line is the look of the address it names, selected by hand: .active_path = try std.testing.allocator.dupe(u8, if (shown.file) |f| f.path else ""), .row = shown.body.cur_row, .missed = p.look_missed, - .msg = try std.testing.allocator.dupe(u8, pane.msg[0..pane.msg_len]), + .msg = try std.testing.allocator.dupe(u8, p.messages.saidBy(pane)), .panes = n, }; } @@ -2868,6 +2889,8 @@ test "Plumb: a look sends what it looks at, the rules written first: a rule's wo const pic = try std.fmt.bufPrint(&pic_buf, "{s}/pic.svg", .{root}); const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 30 }); defer p.deinit(); + // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6). + p.settings.jumps = .@"new-pane"; const pane = try p.setTestFile("see https://ziglang.org here\n"); // The defaults: a URL to the web port, the host's opener; the hover // asks resolve, as before. @@ -2886,7 +2909,7 @@ test "Plumb: a look sends what it looks at, the rules written first: a rule's wo lookAt(p, 0, pic); try std.testing.expectEqual(@as(usize, 0), p.view().active); var said_buf: [4300]u8 = undefined; - try std.testing.expectEqualStrings(try std.fmt.bufPrint(&said_buf, "svg {s}", .{pic}), pane.msg[0..pane.msg_len]); + try std.testing.expectEqualStrings(try std.fmt.bufPrint(&said_buf, "svg {s}", .{pic}), p.messages.saidBy(pane)); // A name open in a pane is focused, never sent. p.look_text = true; lookAt(p, 0, pic); @@ -2897,7 +2920,7 @@ test "Plumb: a look sends what it looks at, the rules written first: a rule's wo p.setMessage(.at(0), "before"); lookAt(p, 0, pic); try std.testing.expectEqual(opened, p.view().active); - try std.testing.expectEqualStrings("before", pane.msg[0..pane.msg_len]); + try std.testing.expectEqualStrings("before", p.messages.saidBy(pane)); // With no web rule, a URL is a word Look searches for. p.view().active = 0; try std.testing.expect(Plumb.apply(p, false, "plumb/rules", "type is text\narg isfile $data\nplumb to edit\n") == null); |
