From d856aba84c051b83199e6d6e3af849e3d54ac9b0 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 28 Mar 2023 09:30:47 -0700 Subject: [PATCH] selection toViewport point should extend to end of last row Fixes #138 --- src/terminal/Selection.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/terminal/Selection.zig b/src/terminal/Selection.zig index 851c69f93..628833372 100644 --- a/src/terminal/Selection.zig +++ b/src/terminal/Selection.zig @@ -20,7 +20,7 @@ end: ScreenPoint, /// of the screen. pub fn toViewport(self: Selection, screen: *const Screen) ?Selection { const top = (point.Viewport{ .x = 0, .y = 0 }).toScreen(screen); - const bot = (point.Viewport{ .x = 0, .y = screen.rows - 1 }).toScreen(screen); + const bot = (point.Viewport{ .x = screen.cols - 1, .y = screen.rows - 1 }).toScreen(screen); // If our selection isn't within the viewport, do nothing. if (!self.within(top, bot)) return null; @@ -103,7 +103,9 @@ pub fn containedRow(self: Selection, screen: *const Screen, p: ScreenPoint) ?Sel if (p.y == tl.y) { // If the selection is JUST this line, return it as-is. - if (p.y == br.y) return self; + if (p.y == br.y) { + return self; + } // Selection top-left line matches only. return .{