diff --git a/src/terminal/Screen.zig b/src/terminal/Screen.zig index 9eec662c0..5fb66b312 100644 --- a/src/terminal/Screen.zig +++ b/src/terminal/Screen.zig @@ -861,6 +861,9 @@ pub fn copyRow(self: *Screen, dst: RowIndex, src: RowIndex) !void { /// /// This can be used to implement terminal scroll regions efficiently. pub fn scrollRegionUp(self: *Screen, top: RowIndex, bottom: RowIndex, count: usize) void { + const tracy = trace(@src()); + defer tracy.end(); + // Avoid a lot of work if we're doing nothing. if (count == 0) return; diff --git a/src/terminal/Terminal.zig b/src/terminal/Terminal.zig index b2f0b7303..d72e01944 100644 --- a/src/terminal/Terminal.zig +++ b/src/terminal/Terminal.zig @@ -732,8 +732,11 @@ pub fn index(self: *Terminal) !void { { try self.screen.scroll(.{ .delta = 1 }); } else { - // TODO: test - try self.scrollUp(1); + self.screen.scrollRegionUp( + .{ .active = self.scrolling_region.top }, + .{ .active = self.scrolling_region.bottom }, + 1, + ); } return; @@ -1251,13 +1254,11 @@ pub fn scrollDown(self: *Terminal, count: usize) !void { /// Does not change the (absolute) cursor position. // TODO: test pub fn scrollUp(self: *Terminal, count: usize) !void { - // Preserve the cursor - const cursor = self.screen.cursor; - defer self.screen.cursor = cursor; - - // Move to the top of the scroll region - self.screen.cursor.y = self.scrolling_region.top; - try self.deleteLines(count); + self.screen.scrollRegionUp( + .{ .active = self.scrolling_region.top }, + .{ .active = self.scrolling_region.bottom }, + count, + ); } /// Options for scrolling the viewport of the terminal grid.