terminal: default for right scroll margin was incorrect

This commit is contained in:
Mitchell Hashimoto
2023-10-10 16:06:27 -07:00
parent 0d2bfacd5b
commit e593ffa264

View File

@ -1827,7 +1827,7 @@ pub fn setLeftAndRightMargin(self: *Terminal, left_req: usize, right_req: usize)
if (!self.modes.get(.enable_left_and_right_margin)) return;
const left = @max(1, left_req);
const right = @min(self.rows, if (right_req == 0) self.rows else right_req);
const right = @min(self.cols, if (right_req == 0) self.cols else right_req);
if (left >= right) return;
self.scrolling_region.left = left - 1;
@ -2760,6 +2760,8 @@ test "Terminal: setLeftAndRightMargin left only" {
try t.printString("GHI");
t.modes.set(.enable_left_and_right_margin, true);
t.setLeftAndRightMargin(2, 0);
try testing.expectEqual(@as(usize, 1), t.scrolling_region.left);
try testing.expectEqual(@as(usize, t.cols - 1), t.scrolling_region.right);
t.setCursorPos(1, 2);
try t.insertLines(1);