mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-25 13:16:11 +03:00
fix crash we can get with horizontal tabs off the end of the screen
This commit is contained in:
@ -665,7 +665,7 @@ pub fn horizontalTab(self: *Terminal) !void {
|
|||||||
const tracy = trace(@src());
|
const tracy = trace(@src());
|
||||||
defer tracy.end();
|
defer tracy.end();
|
||||||
|
|
||||||
while (self.screen.cursor.x < self.cols) {
|
while (self.screen.cursor.x < self.cols - 1) {
|
||||||
// Move the cursor right
|
// Move the cursor right
|
||||||
self.screen.cursor.x += 1;
|
self.screen.cursor.x += 1;
|
||||||
|
|
||||||
@ -1055,7 +1055,7 @@ test "Terminal: backspace" {
|
|||||||
|
|
||||||
test "Terminal: horizontal tabs" {
|
test "Terminal: horizontal tabs" {
|
||||||
const alloc = testing.allocator;
|
const alloc = testing.allocator;
|
||||||
var t = try init(alloc, 80, 5);
|
var t = try init(alloc, 20, 5);
|
||||||
defer t.deinit(alloc);
|
defer t.deinit(alloc);
|
||||||
|
|
||||||
// HT
|
// HT
|
||||||
@ -1066,6 +1066,12 @@ test "Terminal: horizontal tabs" {
|
|||||||
// HT
|
// HT
|
||||||
try t.horizontalTab();
|
try t.horizontalTab();
|
||||||
try testing.expectEqual(@as(usize, 15), t.screen.cursor.x);
|
try testing.expectEqual(@as(usize, 15), t.screen.cursor.x);
|
||||||
|
|
||||||
|
// HT at the end
|
||||||
|
try t.horizontalTab();
|
||||||
|
try testing.expectEqual(@as(usize, 19), t.screen.cursor.x);
|
||||||
|
try t.horizontalTab();
|
||||||
|
try testing.expectEqual(@as(usize, 19), t.screen.cursor.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
test "Terminal: setCursorPosition" {
|
test "Terminal: setCursorPosition" {
|
||||||
|
Reference in New Issue
Block a user