summaryrefslogtreecommitdiff
path: root/core/File.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/File.zig')
-rw-r--r--core/File.zig28
1 files changed, 28 insertions, 0 deletions
diff --git a/core/File.zig b/core/File.zig
index 8e464d61..163f40ff 100644
--- a/core/File.zig
+++ b/core/File.zig
@@ -3679,3 +3679,31 @@ test "Syntax off in a patch's pane takes the language's ink and leaves the patch
if (pass == 1) try std.testing.expect(differ);
}
}
+
+test "a view scrolled by rows into a line of tabs, the tab width changed after a frame: its body drawn from the row the new width makes, as a core loaded from it draws it" {
+ const gpa = std.testing.allocator;
+ const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 });
+ defer p.deinit();
+ var text: std.ArrayList(u8) = .empty;
+ defer text.deinit(gpa);
+ try text.appendSlice(gpa, "head\n");
+ for (0..40) |i| try text.print(gpa, "\tw{d}", .{i});
+ try text.appendSlice(gpa, "\ntail\n");
+ const pane = try p.setTestFile(text.items);
+ try std.testing.expect(p.executeBuiltinLine(0, "Tab 8"));
+ // The top on line 1's fourth row (at 8 cells a tab), drawn.
+ const f = &pane.file.?;
+ f.scroll = 1;
+ f.scroll_row = 3;
+ var arena: std.heap.ArenaAllocator = .init(gpa);
+ defer arena.deinit();
+ _ = try p.render(arena.allocator());
+ try std.testing.expect(p.executeBuiltinLine(0, "Tab 2"));
+ const drawn = try bodyText(p.settings.tab, arena.allocator(), pane, f);
+ const bytes = try pardes.dump.dumpBytes(p);
+ defer gpa.free(bytes);
+ const loaded = try pardes.dump.load(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }, bytes, null);
+ defer loaded.deinit();
+ const lp = loaded.panes[0].?;
+ try std.testing.expectEqualStrings(try bodyText(loaded.settings.tab, arena.allocator(), lp, &lp.file.?), drawn);
+}