summaryrefslogtreecommitdiff
path: root/test/pdf.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-29 20:51:15 -0300
committerGabriel Schneider <[email protected]>2026-10-29 21:03:37 -0300
commitfdf59131f68db19fc4818b6e5db7c9fe4cc609fd (patch)
tree1d3296044f387ec55f66a8d188279ce3eaaa63dc /test/pdf.zig
parenta8d9eb9e5051521aaeb1a95584729794059b5d83 (diff)
downloadpardes-fdf59131f68db19fc4818b6e5db7c9fe4cc609fd.tar.gz
pardes-fdf59131f68db19fc4818b6e5db7c9fe4cc609fd.zip
pdf: Esc in a PDF pane drops the selection or the search highlights the page shows, and with none goes back a pane as Esc does everywhere else; Shift-Esc still goes at once
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'test/pdf.zig')
-rw-r--r--test/pdf.zig29
1 files changed, 23 insertions, 6 deletions
diff --git a/test/pdf.zig b/test/pdf.zig
index 3f84195c..a50f3bf6 100644
--- a/test/pdf.zig
+++ b/test/pdf.zig
@@ -1454,7 +1454,7 @@ test "PDF normal adapter consumes unsupported actions and navigates page fallbac
try std.testing.expect(pane.prompt == .none);
}
-test "Escape cancels PDF chrome in place and Shift-Escape leaves the pane" {
+test "Escape cancels PDF chrome in place, then leaves the pane; Shift-Escape leaves at once" {
if (!pdf_enabled or platform == .web) return;
const gpa = std.testing.allocator;
@@ -1507,15 +1507,32 @@ test "Escape cancels PDF chrome in place and Shift-Escape leaves the pane" {
try std.testing.expectEqual(scroll_before, pv.document_scroll_y);
try std.testing.expectEqual(@as(u32, 0), pane.body.normal.count);
try std.testing.expectEqual(.none, pane.body.normal.prefix);
- // A second Escape on a bare document is inert rather than an exit.
+ // With nothing left to drop, Escape goes back a pane as anywhere else,
+ // and leaves the document as it found it.
p.update(.{ .key = .{ .cp = Key.escape } });
- try std.testing.expectEqual(@as(usize, 0), p.active);
-
- // Shift-Escape is the way out, and it leaves the document as it found it.
- p.update(.{ .key = .{ .cp = Key.escape, .shift = true } });
try std.testing.expectEqual(@as(usize, 1), p.active);
try std.testing.expectEqual(page_before, pv.page);
try std.testing.expectEqual(scroll_before, pv.document_scroll_y);
+
+ // Shift-Escape goes at once, over a selection too.
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ try std.testing.expectEqual(@as(usize, 0), p.active);
+ try std.testing.expectEqual(
+ panes.Pdf.SelectionUpdate.changed,
+ pv.setSelection(p.pdf_gpa, quad.ul, quad.lr, false),
+ );
+ p.update(.{ .key = .{ .cp = Key.escape, .shift = true } });
+ try std.testing.expectEqual(@as(usize, 1), p.active);
+ try std.testing.expect(pv.selection != null);
+
+ // A text-only page shows neither: one Escape drops them and goes.
+ p.native_images = false;
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ try std.testing.expectEqual(@as(usize, 0), p.active);
+ try pv.setSearchQuery(p.pdf_gpa, "Pardes");
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ try std.testing.expectEqual(@as(usize, 1), p.active);
+ try std.testing.expect(pv.selection == null and pv.search_query.len == 0);
}
test "PDF continuous strip renders every intersecting short page" {