mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 01:06:08 +03:00
terminal: scrollRegionUp outside of range does nothing
This commit is contained in:
@ -940,7 +940,10 @@ pub fn scrollRegionUp(self: *Screen, top: RowIndex, bottom: RowIndex, count: usi
|
|||||||
// in the entire screen buffer.
|
// in the entire screen buffer.
|
||||||
const top_y = top.toScreen(self).screen;
|
const top_y = top.toScreen(self).screen;
|
||||||
const bot_y = bottom.toScreen(self).screen;
|
const bot_y = bottom.toScreen(self).screen;
|
||||||
assert(bot_y > top_y);
|
|
||||||
|
// If top is outside of the range of bot, we do nothing.
|
||||||
|
if (top_y >= bot_y) return;
|
||||||
|
|
||||||
assert(count <= (bot_y - top_y));
|
assert(count <= (bot_y - top_y));
|
||||||
|
|
||||||
// Get the storage pointer for the full scroll region. We're going to
|
// Get the storage pointer for the full scroll region. We're going to
|
||||||
@ -2982,6 +2985,23 @@ test "Screen: scrollRegionUp single" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "Screen: scrollRegionUp same line" {
|
||||||
|
const testing = std.testing;
|
||||||
|
const alloc = testing.allocator;
|
||||||
|
|
||||||
|
var s = try init(alloc, 4, 5, 0);
|
||||||
|
defer s.deinit();
|
||||||
|
try s.testWriteString("1ABCD\n2EFGH\n3IJKL\n4ABCD");
|
||||||
|
|
||||||
|
s.scrollRegionUp(.{ .active = 1 }, .{ .active = 1 }, 1);
|
||||||
|
{
|
||||||
|
// Test our contents rotated
|
||||||
|
var contents = try s.testString(alloc, .screen);
|
||||||
|
defer alloc.free(contents);
|
||||||
|
try testing.expectEqualStrings("1ABCD\n2EFGH\n3IJKL\n4ABCD", contents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
test "Screen: scrollRegionUp single with pen" {
|
test "Screen: scrollRegionUp single with pen" {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const alloc = testing.allocator;
|
const alloc = testing.allocator;
|
||||||
|
Reference in New Issue
Block a user