From 360124ded029c9c150a858a0808b008506230f85 Mon Sep 17 00:00:00 2001 From: Qwerasd Date: Wed, 25 Jun 2025 23:16:43 -0600 Subject: [PATCH] terminal/Screen: account for rectangle selection in clone Fixes an issue where rectangle selections would appear visually wrong if their start or end were out of the viewport area, because when cloning them the restored pins were defaulting to the start and end of the row instead of the appropriate column. --- src/terminal/Screen.zig | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index 2688b03a7..deff4a394 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -402,8 +402,8 @@ pub fn clonePool( }; const start_pin = pin_remap.get(ordered.tl) orelse start: { - // No start means it is outside the cloned area. We change it - // to the top-left. + // No start means it is outside the cloned area. + // We move it back in bounds to the top row. // If we have no end pin then either // (1) our whole selection is outside the cloned area or @@ -417,14 +417,17 @@ pub fn clonePool( if (!sel.contains(self, clone_top)) break :sel null; } - break :start try pages.trackPin(.{ .node = pages.pages.first.? }); + break :start try pages.trackPin(.{ + .node = pages.pages.first.?, + .x = if (sel.rectangle) ordered.tl.x else 0, + }); }; const end_pin = pin_remap.get(ordered.br) orelse end: { - // No end means it is outside the cloned area. We change it - // to the bottom-right. + // No end means it is outside the cloned area. + // We move it back in bounds to the bottom row. break :end try pages.trackPin(pages.pin(.{ .active = .{ - .x = pages.cols - 1, + .x = if (sel.rectangle) ordered.br.x else pages.cols - 1, .y = pages.rows - 1, } }) orelse break :sel null); };