diff options
Diffstat (limited to 'core/Trail.zig')
| -rw-r--r-- | core/Trail.zig | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/core/Trail.zig b/core/Trail.zig index e22a58b6..c2c1b0c3 100644 --- a/core/Trail.zig +++ b/core/Trail.zig @@ -194,8 +194,11 @@ pub fn replaceStep(p: *Pardes, id: usize, path: []const u8, at: Spot) !usize { } /// Pane `id` showing `path` at `at`, the keyboard on it: its caret moved -/// in the file it shows, or a new pane on `path` in its place, its walk -/// with it. A line past the new file's end is a miss that changes nothing. +/// in the file it shows, or `path` opened in its place as the same pane, as +/// acme's Get keeps a window's id: its walk, its serial (`@pN`, a script's +/// `/pane/N`), the 9P state its scripts hold and its /log record (a rename), +/// the file it left closed as any (Recent keeps its place). A line past the +/// new file's end is a miss that changes nothing. fn show(p: *Pardes, id: usize, path: []const u8, at: Spot) !usize { const pane = p.panes[id].?; if (pane.file) |f| if (std.mem.eql(u8, f.path, path)) { @@ -213,11 +216,23 @@ fn show(p: *Pardes, id: usize, path: []const u8, at: Spot) !usize { } if (at.line > panes.File.nlines(p.gpa, &nt.file.?)) return error.LineMissing; nt.trail = pane.trail; + // What jj answered for the file it leaves goes with that file; its + // text a revision on from the one it leaves, so nothing a worker was + // asked of that text (a parse, a paint, both by serial and revision) + // lands on this one. + @import("jj.zig").forget(p, pane.serial); + nt.serial = pane.serial; + nt.file.?.revision = if (pane.file) |f| f.revision +% 1 else 0; + nt.file.?.saved_revision = nt.file.?.revision; + // Its 9P state: the one never announced leaves with no record. + std.mem.swap(@TypeOf(pane.fs), &nt.fs, &pane.fs); // Before the layout gives its place away: its file is told closed // while it is still in its slot. try panes.deinitPane(p, pane); layout.replacePane(p, id, free); p.panes[id] = null; + pardes.ctlfs.events.noteLog(p, .rename, nt); + if (pardes.Pardes.onDisk(nt)) p.recent.opened(p.recentGpa(), path); lift(p, free); look.focusPaneLine(p, free, at, .keep); // Its line half the body's rows down, as a look's new pane has it. @@ -751,8 +766,9 @@ test "the session of pick-ui ยง6.7: four jumps across three files, back by a cli var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); defer arena.deinit(); const s = try p.render(arena.allocator()); + // In the dim ink of the reading tag's ground (UX D4: 3:1 at least). const dim = try tagCell(p, r, "place.zig:40"); - try std.testing.expectEqual(pardes.Color{ .rgb = p.chromeTheme().lineno }, s.at(dim[0], dim[1]).style.fg); + try std.testing.expectEqual(pardes.Color{ .rgb = p.chromeTheme().roles.on(.reading_focused).dim }, s.at(dim[0], dim[1]).style.fg); // A click on a forward step goes forward to it. try clickTag(p, r, "place.zig:9", .left); r = p.view().active; @@ -839,7 +855,8 @@ test "a trail keeps its newest three back steps whole, older ones fold into one defer arena.deinit(); const s = try p.render(arena.allocator()); const fold = try tagCell(p, r, "+2"); - try std.testing.expectEqual(pardes.Color{ .rgb = p.chromeTheme().lineno }, s.at(fold[0], fold[1]).style.fg); + // In the dim ink of the reading tag's ground (UX D4). + try std.testing.expectEqual(pardes.Color{ .rgb = p.chromeTheme().roles.on(.reading_focused).dim }, s.at(fold[0], fold[1]).style.fg); try clickTag(p, r, "+2", .right); try std.testing.expectEqualStrings("rank.zig:20", f.at(&at)); // Back at the first: five forward steps, the two nearest whole. @@ -898,6 +915,8 @@ test "two steps whose files have the same name are told apart by the shortest pa const s = try p.render(arena.allocator()); const word = try tagCell(p, r, "Find x 1/2"); try std.testing.expect(s.at(word[0], word[1]).style.ul == .single); + // In the key ink (UX D8, D4). + try std.testing.expectEqual(pardes.Color{ .rgb = p.chromeTheme().roles.key }, s.at(word[0], word[1]).style.fg); const other = try tagCell(p, r, "place.zig"); try std.testing.expect(s.at(other[0], other[1]).style.ul != .single); } |
