From 5c04ebe3bdc739e4b0d8e1727da0c3d678b72c3f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 5 Mar 2024 22:32:13 -0800 Subject: [PATCH] terminal2: adjust down edges --- src/terminal/Selection.zig | 2 ++ src/terminal2/Selection.zig | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/terminal/Selection.zig b/src/terminal/Selection.zig index bd7553aa9..398875b0e 100644 --- a/src/terminal/Selection.zig +++ b/src/terminal/Selection.zig @@ -485,6 +485,7 @@ test "Selection: adjust up" { } } +// X test "Selection: adjust down" { const testing = std.testing; var screen = try Screen.init(testing.allocator, 5, 10, 0); @@ -520,6 +521,7 @@ test "Selection: adjust down" { } } +// X test "Selection: adjust down with not full screen" { const testing = std.testing; var screen = try Screen.init(testing.allocator, 5, 10, 0); diff --git a/src/terminal2/Selection.zig b/src/terminal2/Selection.zig index a35dbfca9..184d89468 100644 --- a/src/terminal2/Selection.zig +++ b/src/terminal2/Selection.zig @@ -482,6 +482,35 @@ test "Selection: adjust down" { } } +test "Selection: adjust down with not full screen" { + const testing = std.testing; + var s = try Screen.init(testing.allocator, 5, 10, 0); + defer s.deinit(); + try s.testWriteString("A\nB\nC"); + + // On the last line + { + var sel = try Selection.init( + &s, + s.pages.pin(.{ .screen = .{ .x = 4, .y = 1 } }).?, + s.pages.pin(.{ .screen = .{ .x = 3, .y = 2 } }).?, + false, + ); + defer sel.deinit(&s); + sel.adjust(&s, .down); + + // Start line + try testing.expectEqual(point.Point{ .screen = .{ + .x = 4, + .y = 1, + } }, s.pages.pointFromPin(.screen, sel.start.*).?); + try testing.expectEqual(point.Point{ .screen = .{ + .x = 4, + .y = 2, + } }, s.pages.pointFromPin(.screen, sel.end.*).?); + } +} + test "Selection: order, standard" { const testing = std.testing; const alloc = testing.allocator;