diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-21 07:02:01 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-21 07:02:01 -0300 |
| commit | f7de6f49ee3d9ac241575f5244743193c9943841 (patch) | |
| tree | 9f77af1eab8bfba6a4c8cfc75fe5ec646d517ffe /core/jj.zig | |
| parent | 78a022adb2a657711f706fcaae7c2abb412dac9c (diff) | |
| download | pardes-f7de6f49ee3d9ac241575f5244743193c9943841.tar.gz pardes-f7de6f49ee3d9ac241575f5244743193c9943841.zip | |
layers: what round 1 left, three places where a revision's pane or a patch's did not do what the design's words say: a B3 click on path@rev[:line] in running text opens the file at that revision there (the click already expanded the whole token, @ being a file character; jj's test now drives it through the mouse); a revision's text is read-only over 9P too: an open of its body, data, xdata or sel to write is refused in words ("a revision is read-only", errno EROFS, as enameErrno reads the words: core/ninep/tree.zig's open, the one road 9P has to the text; the editor's own two are File.edit's splice and edit.zig's whole text), where before the write reached File.edit and was answered "out of memory"; Syntax off in a patch's pane takes the language's ink and leaves the patch: its bytes are made again once a paint without the language's (syntax.highlightDiffPlain), grounds, markers and changed words as they were (round 1 took them too); tests: the click, the four opens, a .zig patch's cells' grounds the same and its ink not; tui core-test 893/1053 (160 skipped)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/jj.zig')
| -rw-r--r-- | core/jj.zig | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/core/jj.zig b/core/jj.zig index 429ea9c9..7784c1c1 100644 --- a/core/jj.zig +++ b/core/jj.zig @@ -419,3 +419,52 @@ test "provenance: a value a line, which pinned change wrote it, from what jj ans }, } } + +test "a B3 click on path@rev:line in running text opens the file at that revision there" { + const gpa = testing.allocator; + var repo = try Repo.init(gpa) orelse return error.SkipZigTest; + defer repo.deinit(gpa); + try repo.tmp.dir.writeFile(testing.io, .{ .sub_path = "notes.txt", .data = "see a.zig@@-:2 here\n" }); + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 30 }); + defer p.deinit(); + var line: [4200]u8 = undefined; + p.update(.{ .command = try std.fmt.bufPrint(&line, "Look {s}/notes.txt", .{repo.dir}) }); + const notes = p.view().active; + p.sync(); + var arena: std.heap.ArenaAllocator = .init(gpa); + defer arena.deinit(); + const s = try p.render(arena.allocator()); + const body = s.region(.body, notes).?.rect; + // On the `@` of the address, the body's first row. + const x: u16 = body.x + File.gutterWidth(p.panes[notes].?) + @as(u16, "see a.zig".len); + p.update(.{ .mouse = .{ .button = .right, .kind = .press, .col = x, .row = body.y } }); + p.update(.{ .mouse = .{ .button = .right, .kind = .release, .col = x, .row = body.y } }); + const shown = p.view().active; + try testing.expect(shown != notes); + const f = &p.panes[shown].?.file.?; + try testing.expect(of(f) != null); + try testing.expectEqualStrings(Repo.two, f.content); + try testing.expectEqual(@as(i32, 1), p.panes[shown].?.body.cur_row); +} + +test "a revision's text is read-only over 9P too: an open to write it is refused in words" { + const gpa = testing.allocator; + var repo = try Repo.init(gpa) orelse return error.SkipZigTest; + defer repo.deinit(gpa); + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 30 }); + defer p.deinit(); + var line: [4200]u8 = undefined; + p.update(.{ .command = try std.fmt.bufPrint(&line, "Look {s}@@-", .{repo.file}) }); + const pane = p.panes[p.view().active].?; + try testing.expect(of(&pane.file.?) != null); + const th = @import("ninep/harness.zig"); + const tree = @import("ninep/tree.zig"); + for ([_]tree.PaneFile{ .body, .data, .xdata, .sel }) |file| { + const got = th.call(p, .{ .tag = 1, .op = .open, .node = tree.Node.of(pane.serial, file), .omode = 1 }); + try testing.expectEqual(@as(u16, 30), got.errno()); + try testing.expectEqual(@as(u16, 30), @import("cloud9").fs.enameErrno(got.reply.ename)); + } + // Reading it is as any text's. + try testing.expectEqual(@as(u16, 0), th.call(p, .{ .tag = 1, .op = .open, .node = tree.Node.of(pane.serial, .body), .omode = 0 }).errno()); + try testing.expectEqualStrings(Repo.two, pane.file.?.content); +} |
