diff options
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 159 |
1 files changed, 1 insertions, 158 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index 3ecc80ae..151fe7b0 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -751,13 +751,6 @@ test "Collapse builtin keeps content and restores the pane from its default tag" p.sync(); try std.testing.expect(!pane.collapsed); try std.testing.expectEqual(height, p.rects[0].h); - - // Unedited defaults from the preceding version gain the new command. - if (pane.tag.own) |own| p.gpa.free(own); - pane.tag.own = null; - tagline.restoreTailAt(p, pane, tagline.pre_collapse_file_pane_tail, "", .file); - try std.testing.expect(pane.tag.own == null); - try std.testing.expectEqualStrings(tagline.file_pane_tail, tagline.curTail(pane)); } test "LocationsConfig command reports partial updates and survives restore" { @@ -985,129 +978,6 @@ test "compact tag commands stay beside their own prefix across layout changes" { try std.testing.expectEqualStrings(above_tag, try tagline.tagText(p, p.scratch.allocator(), above)); } -test "legacy default tag tails upgrade while custom tails remain owned" { - const gpa = std.testing.allocator; - const p = try Pardes.init(gpa, .{}); - defer p.deinit(); - - const terminal = p.panes[0].?; - const terminal_old = try std.fmt.allocPrint(p.scratch.allocator(), "{s}{s}", .{ - try tagline.tagPrefix(p, terminal), - tagline.legacy_pane_tail, - }); - tagline.restoreTail(p, terminal, terminal_old); - try std.testing.expect(terminal.tag.own == null); - try std.testing.expectEqualStrings(tagline.terminal_pane_tail, tagline.curTail(terminal)); - - const terminal_previous = try std.fmt.allocPrint(p.scratch.allocator(), "{s} New Del", .{ - try tagline.tagPrefix(p, terminal), - }); - tagline.restoreTail(p, terminal, terminal_previous); - try std.testing.expect(terminal.tag.own == null); - try std.testing.expectEqualStrings(tagline.terminal_pane_tail, tagline.curTail(terminal)); - - const terminal_prefilter = try std.fmt.allocPrint(p.scratch.allocator(), "{s}{s}", .{ - try tagline.tagPrefix(p, terminal), - tagline.prev_terminal_pane_tail, - }); - tagline.restoreTail(p, terminal, terminal_prefilter); - try std.testing.expect(terminal.tag.own == null); - try std.testing.expectEqualStrings(tagline.terminal_pane_tail, tagline.curTail(terminal)); - - for ([_][]const u8{ tagline.pre_mode_terminal_pane_tail, tagline.pre_tty_first_terminal_pane_tail, tagline.pre_collapse_terminal_pane_tail }) |old_tail| { - const old = try std.fmt.allocPrint(p.scratch.allocator(), "{s}{s}", .{ try tagline.tagPrefix(p, terminal), old_tail }); - tagline.restoreTail(p, terminal, old); - try std.testing.expect(terminal.tag.own == null); - try std.testing.expectEqualStrings(tagline.terminal_pane_tail, tagline.curTail(terminal)); - } - const custom_mode = try std.fmt.allocPrint(p.scratch.allocator(), "{s}{s} Keep", .{ try tagline.tagPrefix(p, terminal), tagline.pre_mode_terminal_pane_tail }); - tagline.restoreTail(p, terminal, custom_mode); - try std.testing.expect(terminal.tag.own != null); - try std.testing.expectEqualStrings(tagline.pre_mode_terminal_pane_tail ++ " Keep", tagline.curTail(terminal)); - - if (terminal.tag.own) |own| p.gpa.free(own); - terminal.tag.own = null; - const terminal_custom = try std.fmt.allocPrint(p.scratch.allocator(), "{s} Keep Del", .{ - try tagline.tagPrefix(p, terminal), - }); - tagline.restoreTail(p, terminal, terminal_custom); - try std.testing.expect(terminal.tag.own != null); - try std.testing.expectEqualStrings(" Keep Del", tagline.curTail(terminal)); - - if (terminal.tag.own) |own| p.gpa.free(own); - terminal.tag.own = null; - tagline.restoreDumpTail(p, terminal, .{ - .kind = .terminal, - .tag = "TTY /historical/cwd Keep Del", - .body = "", - .terminal = .{ .cwd = "/historical/cwd" }, - }); - try std.testing.expect(terminal.tag.own != null); - try std.testing.expectEqualStrings(" Keep Del", tagline.curTail(terminal)); - - if (terminal.tag.own) |own| p.gpa.free(own); - terminal.tag.own = null; - tagline.restoreDumpTail(p, terminal, .{ - .kind = .terminal, - .tag = "TTY /historical/cwd New Del", - .body = "", - .terminal = .{ .cwd = "/historical/cwd" }, - }); - try std.testing.expect(terminal.tag.own == null); - try std.testing.expectEqualStrings(tagline.terminal_pane_tail, tagline.curTail(terminal)); - - // This happens to be the historical FILE default, but on a terminal it is - // user-owned text and must not be swallowed by migration. - if (terminal.tag.own) |own| p.gpa.free(own); - terminal.tag.own = null; - const terminal_fileish = try std.fmt.allocPrint(p.scratch.allocator(), "{s} Save Del", .{ - try tagline.tagPrefix(p, terminal), - }); - tagline.restoreTail(p, terminal, terminal_fileish); - try std.testing.expect(terminal.tag.own != null); - try std.testing.expectEqualStrings(" Save Del", tagline.curTail(terminal)); - - // A savable file has a distinct old default. Save remains first after the - // migration so the tag's established `:w<Tab>` route is unchanged. - const file = try p.setTestFile(""); - const file_old = try std.fmt.allocPrint(p.scratch.allocator(), "{s}{s}", .{ - try tagline.tagPrefix(p, file), - tagline.legacy_file_pane_tail, - }); - tagline.restoreTail(p, file, file_old); - try std.testing.expect(file.tag.own == null); - try std.testing.expectEqualStrings(" Save Tty Collapse Del", tagline.curTail(file)); - - const file_custom = try std.fmt.allocPrint(p.scratch.allocator(), "{s} Save Mine Del", .{ - try tagline.tagPrefix(p, file), - }); - tagline.restoreTail(p, file, file_custom); - try std.testing.expect(file.tag.own != null); - try std.testing.expectEqualStrings(" Save Mine Del", tagline.curTail(file)); - - // Conversely the generic pane's current default is a custom edit on a - // savable file. Legacy recognition is scoped to the source pane class. - if (file.tag.own) |own| p.gpa.free(own); - file.tag.own = null; - const file_generic = try std.fmt.allocPrint(p.scratch.allocator(), "{s} New Del", .{ - try tagline.tagPrefix(p, file), - }); - tagline.restoreTail(p, file, file_generic); - try std.testing.expect(file.tag.own != null); - try std.testing.expectEqualStrings(" New Del", tagline.curTail(file)); - - const image_doc = try panes.Image.create(p, 1, "/tmp/legacy image.ppm", &.{}); - try std.testing.expectEqualStrings(" Tty Collapse Del", tagline.curTail(image_doc)); - tagline.restoreDumpTail(p, image_doc, .{ - .kind = .image, - .tag = "img /tmp/legacy image.ppm Keep Del", - .body = "", - .image = .{ .path = "/tmp/legacy image.ppm" }, - }); - try std.testing.expect(image_doc.tag.own != null); - try std.testing.expectEqualStrings(" Keep Del", tagline.curTail(image_doc)); -} - test "Joincol folds the active column into its right neighbor, keeping its panes" { const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 30 }); @@ -1434,14 +1304,6 @@ test "pane defaults keep creation of scratch panes in column tags" { while (words.next()) |word| try std.testing.expect(!std.mem.eql(u8, word, "New")); } try std.testing.expectEqualStrings("New Tty Find Grep Joincol Delcol", tagline.columnTag(p, 0)); - const terminal = p.panes[0].?; - tagline.restoreTailAt(p, terminal, tagline.pre_column_terminal_pane_tail, "", .terminal); - try std.testing.expect(terminal.tag.own == null); - try std.testing.expectEqualStrings(tagline.terminal_pane_tail, tagline.curTail(terminal)); - const file = try p.setTestFile("unchanged\n"); - tagline.restoreTailAt(p, file, tagline.pre_column_file_pane_tail, "", .file); - try std.testing.expect(file.tag.own == null); - try std.testing.expectEqualStrings(tagline.file_pane_tail, tagline.curTail(file)); } test "an unsaved file's tag is its name alone: the grip, not a mark, says it is unsaved" { @@ -2640,27 +2502,8 @@ test "Save reaches every tagline with text behind it and no other" { out.file.?.output = .{ .from = .search }; try std.testing.expectEqualStrings(tagline.locations_pane_tail, tagline.curTail(out)); - // A dump written before Save reached output buffers carries the generic - // tail. That is a DEFAULT and not something typed, so it upgrades. - const dumped = try std.fmt.allocPrint(p.scratch.allocator(), "{s}{s}", .{ - try tagline.tagPrefix(p, out), - tagline.pane_tail, - }); - tagline.restoreTail(p, out, dumped); - try std.testing.expect(out.tag.own == null); - try std.testing.expectEqualStrings(tagline.locations_pane_tail, tagline.curTail(out)); - - // A scratch is an output buffer that has worn the FILE tails all along, - // so its own older default upgrades from that family too. + // A scratch is an output buffer that wears the FILE tails. out.file.?.output = .{ .from = .{ .cmd = std.meta.stringToEnum(Builtin, "New").? } }; - if (out.tag.own) |own| p.gpa.free(own); - out.tag.own = null; - const scratch_dumped = try std.fmt.allocPrint(p.scratch.allocator(), "{s}{s}", .{ - try tagline.tagPrefix(p, out), - tagline.prev_file_pane_tail, - }); - tagline.restoreTail(p, out, scratch_dumped); - try std.testing.expect(out.tag.own == null); try std.testing.expectEqualStrings(" Save Tty Collapse Del", tagline.curTail(out)); // An image's bytes on disk already are what they are: nothing of the |
