terminal: failing tracked pin test on fullReset

This commit is contained in:
Mitchell Hashimoto
2024-12-02 09:39:21 -05:00
parent 2cb334f293
commit d57d1d2395
2 changed files with 15 additions and 1 deletions

View File

@ -2356,7 +2356,11 @@ pub fn countTrackedPins(self: *const PageList) usize {
/// Checks if a pin is valid for this pagelist. This is a very slow and /// Checks if a pin is valid for this pagelist. This is a very slow and
/// expensive operation since we traverse the entire linked list in the /// expensive operation since we traverse the entire linked list in the
/// worst case. Only for runtime safety/debug. /// worst case. Only for runtime safety/debug.
fn pinIsValid(self: *const PageList, p: Pin) bool { pub fn pinIsValid(self: *const PageList, p: Pin) bool {
// This is very slow so we want to ensure we only ever
// call this during slow runtime safety builds.
comptime assert(build_config.slow_runtime_safety);
var it = self.pages.first; var it = self.pages.first;
while (it) |node| : (it = node.next) { while (it) |node| : (it = node.next) {
if (node != p.node) continue; if (node != p.node) continue;

View File

@ -10575,6 +10575,16 @@ test "Terminal: fullReset default modes" {
try testing.expect(t.modes.get(.grapheme_cluster)); try testing.expect(t.modes.get(.grapheme_cluster));
} }
test "Terminal: fullReset tracked pins" {
var t = try init(testing.allocator, .{ .cols = 80, .rows = 80 });
defer t.deinit(testing.allocator);
// Create a tracked pin
const p = try t.screen.pages.trackPin(t.screen.cursor.page_pin.*);
t.fullReset();
try testing.expect(t.screen.pages.pinIsValid(p.*));
}
// https://github.com/mitchellh/ghostty/issues/272 // https://github.com/mitchellh/ghostty/issues/272
// This is also tested in depth in screen resize tests but I want to keep // This is also tested in depth in screen resize tests but I want to keep
// this test around to ensure we don't regress at multiple layers. // this test around to ensure we don't regress at multiple layers.