mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
terminal: delete lines outside of scroll region should do nothing
This commit is contained in:
@ -1425,6 +1425,13 @@ pub fn deleteLines(self: *Terminal, count: usize) !void {
|
||||
const tracy = trace(@src());
|
||||
defer tracy.end();
|
||||
|
||||
// If our cursor is outside of the scroll region, do nothing.
|
||||
if (self.screen.cursor.y < self.scrolling_region.top or
|
||||
self.screen.cursor.y > self.scrolling_region.bottom)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Move the cursor to the left margin
|
||||
self.screen.cursor.x = 0;
|
||||
|
||||
@ -2132,6 +2139,34 @@ test "Terminal: deleteLines with scroll region, large count" {
|
||||
}
|
||||
}
|
||||
|
||||
test "Terminal: deleteLines with scroll region, cursor outside of region" {
|
||||
const alloc = testing.allocator;
|
||||
var t = try init(alloc, 80, 80);
|
||||
defer t.deinit(alloc);
|
||||
|
||||
// Initial value
|
||||
try t.print('A');
|
||||
t.carriageReturn();
|
||||
try t.linefeed();
|
||||
try t.print('B');
|
||||
t.carriageReturn();
|
||||
try t.linefeed();
|
||||
try t.print('C');
|
||||
t.carriageReturn();
|
||||
try t.linefeed();
|
||||
try t.print('D');
|
||||
|
||||
t.setScrollingRegion(1, 3);
|
||||
t.setCursorPos(4, 1);
|
||||
try t.deleteLines(1);
|
||||
|
||||
{
|
||||
var str = try t.plainString(testing.allocator);
|
||||
defer testing.allocator.free(str);
|
||||
try testing.expectEqualStrings("A\nB\nC\nD", str);
|
||||
}
|
||||
}
|
||||
|
||||
test "Terminal: insertLines" {
|
||||
const alloc = testing.allocator;
|
||||
var t = try init(alloc, 2, 5);
|
||||
|
Reference in New Issue
Block a user