summaryrefslogtreecommitdiff
path: root/test/pdf.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-15 20:17:50 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:14 -0300
commit179863c0a7b011d5a4bd5e064f7d021d239aa96e (patch)
tree02f56d75f3627de575b912d22418e5b4e0eb7d0f /test/pdf.zig
parentffa2fd2d4b40bc4ff2a05263cf82ee9638590edd (diff)
downloadpardes-179863c0a7b011d5a4bd5e064f7d021d239aa96e.tar.gz
pardes-179863c0a7b011d5a4bd5e064f7d021d239aa96e.zip
Clear selections when navigating Back and Forward
Diffstat (limited to 'test/pdf.zig')
-rw-r--r--test/pdf.zig27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/pdf.zig b/test/pdf.zig
index 7a05447e..beeb0b40 100644
--- a/test/pdf.zig
+++ b/test/pdf.zig
@@ -2055,3 +2055,30 @@ test "Esc back into a PDF keeps the offset within its page" {
// snap, so a test that watched the offset alone would not see it coming.
try std.testing.expect(!pv.scroll_to_page_pending);
}
+
+test "PDF Back and Forward clear selections and land on recorded pages" {
+ if (!pdf_enabled or platform == .web) return error.SkipZigTest;
+ const p = try Pardes.init(std.testing.allocator, .{ .file = "docs/design.pdf", .cols = 80, .rows = 28 });
+ defer p.deinit();
+ p.native_images = true;
+ p.presentation.enabled = false;
+ const pane = p.panes[0].?;
+ const state = &pane.pdf.?;
+ try std.testing.expect(state.page_count > 1);
+ try std.testing.expect(state.focusLocation(p.pdf_gpa, 2, 0));
+ p.njumps = 2;
+ p.jcur = 1;
+ p.jumps[0] = .{ .pane = 0, .serial = pane.serial, .line = 1, .col = 0 };
+ p.jumps[1] = .{ .pane = 0, .serial = pane.serial, .line = 2, .col = 0 };
+ for ([_]u21{ 'o', 'i' }, 0..) |key, destination| {
+ try std.testing.expectEqual(panes.Pdf.SelectionUpdate.changed, state.setSelection(p.pdf_gpa, .{ .x = 0, .y = 0 }, .{ .x = 1, .y = 1 }, true));
+ try std.testing.expect(state.selection != null and state.selection_text.len > 0);
+ p.update(.{ .key = .{ .cp = key, .ctrl = true } });
+ try std.testing.expectEqual(destination, p.jcur);
+ try std.testing.expectEqual(destination, state.page);
+ try std.testing.expect(state.selection == null);
+ try std.testing.expect(state.selection_page == null);
+ try std.testing.expectEqual(@as(usize, 0), state.selection_text.len);
+ try std.testing.expect(state.drag_anchor == null and state.drag_head == null);
+ }
+}