aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/terminal/search/sliding_window.zig
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-09-10 21:51:57 +0300
committerGitHub <noreply@github.com>2026-09-10 21:51:57 +0300
commit425c86179791cd32e2d4ce0ae7f269940b4b0663 (patch)
treee52c4383a6d69216cbe2a32638bf90841d7e2189 /vendor/libghostty-vt/src/terminal/search/sliding_window.zig
parent90e947a6e26e02f10ec7f1694c4eb5b78a86406b (diff)
chore: upgrade libghostty and preserve terminal behavior (#3906)
Diffstat (limited to 'vendor/libghostty-vt/src/terminal/search/sliding_window.zig')
-rw-r--r--vendor/libghostty-vt/src/terminal/search/sliding_window.zig79
1 files changed, 52 insertions, 27 deletions
diff --git a/vendor/libghostty-vt/src/terminal/search/sliding_window.zig b/vendor/libghostty-vt/src/terminal/search/sliding_window.zig
index 2f858ec8..95b37d73 100644
--- a/vendor/libghostty-vt/src/terminal/search/sliding_window.zig
+++ b/vendor/libghostty-vt/src/terminal/search/sliding_window.zig
@@ -714,14 +714,15 @@ test "SlidingWindow empty on init" {
test "SlidingWindow empty needle has no matches" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .forward, "");
defer w.deinit();
- var s = try Screen.init(alloc, .{
+ var s = try Screen.init(io, alloc, .{
.cols = 80,
.rows = 24,
- .max_scrollback = 0,
+ .max_scrollback_bytes = 0,
});
defer s.deinit();
try s.testWriteString("hello");
@@ -733,11 +734,12 @@ test "SlidingWindow empty needle has no matches" {
test "SlidingWindow single append" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .forward, "boo!");
defer w.deinit();
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 0 });
defer s.deinit();
try s.testWriteString("hello. boo! hello. boo!");
@@ -778,11 +780,12 @@ test "SlidingWindow single append" {
test "SlidingWindow single append case insensitive ASCII" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .forward, "Boo!");
defer w.deinit();
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 0 });
defer s.deinit();
try s.testWriteString("hello. boo! hello. boo!");
@@ -823,11 +826,12 @@ test "SlidingWindow single append case insensitive ASCII" {
test "SlidingWindow single append single char" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .forward, "b");
defer w.deinit();
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 0 });
defer s.deinit();
try s.testWriteString("hello. boo! hello. boo!");
@@ -868,11 +872,12 @@ test "SlidingWindow single append single char" {
test "SlidingWindow single append no match" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .forward, "nope!");
defer w.deinit();
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 0 });
defer s.deinit();
try s.testWriteString("hello. boo! hello. boo!");
@@ -892,11 +897,12 @@ test "SlidingWindow single append no match" {
test "SlidingWindow two pages" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .forward, "boo!");
defer w.deinit();
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 1000 });
defer s.deinit();
// Fill up the first page. The final bytes in the first page
@@ -947,11 +953,12 @@ test "SlidingWindow two pages" {
test "SlidingWindow two pages single char" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .forward, "b");
defer w.deinit();
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 1000 });
defer s.deinit();
// Fill up the first page. The final bytes in the first page
@@ -1002,11 +1009,12 @@ test "SlidingWindow two pages single char" {
test "SlidingWindow two pages match across boundary" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .forward, "hello, world");
defer w.deinit();
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 1000 });
defer s.deinit();
// Fill up the first page. The final bytes in the first page
@@ -1047,11 +1055,12 @@ test "SlidingWindow two pages match across boundary" {
test "SlidingWindow two pages no match across boundary with newline" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .forward, "hello, world");
defer w.deinit();
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 1000 });
defer s.deinit();
// Fill up the first page. The final bytes in the first page
@@ -1080,11 +1089,12 @@ test "SlidingWindow two pages no match across boundary with newline" {
test "SlidingWindow two pages no match across boundary with newline reverse" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .reverse, "hello, world");
defer w.deinit();
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 1000 });
defer s.deinit();
// Fill up the first page. The final bytes in the first page
@@ -1110,11 +1120,12 @@ test "SlidingWindow two pages no match across boundary with newline reverse" {
test "SlidingWindow two pages no match prunes first page" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .forward, "nope!");
defer w.deinit();
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 1000 });
defer s.deinit();
// Fill up the first page. The final bytes in the first page
@@ -1145,8 +1156,9 @@ test "SlidingWindow two pages no match prunes first page" {
test "SlidingWindow two pages no match keeps both pages" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 1000 });
defer s.deinit();
// Fill up the first page. The final bytes in the first page
@@ -1185,11 +1197,12 @@ test "SlidingWindow two pages no match keeps both pages" {
test "SlidingWindow single append across circular buffer boundary" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .forward, "abc");
defer w.deinit();
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 0 });
defer s.deinit();
try s.testWriteString("XXXXXXXXXXXXXXXXXXXboo!XXXXX");
@@ -1241,11 +1254,12 @@ test "SlidingWindow single append across circular buffer boundary" {
test "SlidingWindow single append match on boundary" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .forward, "abcd");
defer w.deinit();
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 0 });
defer s.deinit();
try s.testWriteString("o!XXXXXXXXXXXXXXXXXXXbo");
@@ -1300,11 +1314,12 @@ test "SlidingWindow single append match on boundary" {
test "SlidingWindow single append reversed" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .reverse, "boo!");
defer w.deinit();
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 0 });
defer s.deinit();
try s.testWriteString("hello. boo! hello. boo!");
@@ -1345,11 +1360,12 @@ test "SlidingWindow single append reversed" {
test "SlidingWindow single append no match reversed" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .reverse, "nope!");
defer w.deinit();
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 0 });
defer s.deinit();
try s.testWriteString("hello. boo! hello. boo!");
@@ -1369,11 +1385,12 @@ test "SlidingWindow single append no match reversed" {
test "SlidingWindow two pages reversed" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .reverse, "boo!");
defer w.deinit();
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 1000 });
defer s.deinit();
// Fill up the first page. The final bytes in the first page
@@ -1424,11 +1441,12 @@ test "SlidingWindow two pages reversed" {
test "SlidingWindow two pages match across boundary reversed" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .reverse, "hello, world");
defer w.deinit();
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 1000 });
defer s.deinit();
// Fill up the first page. The final bytes in the first page
@@ -1479,11 +1497,12 @@ test "SlidingWindow two pages match across boundary reversed" {
test "SlidingWindow two pages no match prunes first page reversed" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .reverse, "nope!");
defer w.deinit();
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 1000 });
defer s.deinit();
// Fill up the first page. The final bytes in the first page
@@ -1514,8 +1533,9 @@ test "SlidingWindow two pages no match prunes first page reversed" {
test "SlidingWindow two pages no match keeps both pages reversed" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 1000 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 1000 });
defer s.deinit();
// Fill up the first page. The final bytes in the first page
@@ -1554,11 +1574,12 @@ test "SlidingWindow two pages no match keeps both pages reversed" {
test "SlidingWindow single append across circular buffer boundary reversed" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .reverse, "abc");
defer w.deinit();
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 0 });
defer s.deinit();
try s.testWriteString("XXXXXXXXXXXXXXXXXXXboo!XXXXX");
@@ -1611,11 +1632,12 @@ test "SlidingWindow single append across circular buffer boundary reversed" {
test "SlidingWindow single append match on boundary reversed" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .reverse, "abcd");
defer w.deinit();
- var s = try Screen.init(alloc, .{ .cols = 80, .rows = 24, .max_scrollback = 0 });
+ var s = try Screen.init(io, alloc, .{ .cols = 80, .rows = 24, .max_scrollback_bytes = 0 });
defer s.deinit();
try s.testWriteString("o!XXXXXXXXXXXXXXXXXXXbo");
@@ -1671,11 +1693,12 @@ test "SlidingWindow single append match on boundary reversed" {
test "SlidingWindow single append soft wrapped" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .forward, "boo!");
defer w.deinit();
- var t: Terminal = try .init(alloc, .{ .cols = 4, .rows = 5 });
+ var t: Terminal = try .init(io, alloc, .{ .cols = 4, .rows = 5 });
defer t.deinit(alloc);
var s = t.vtStream();
@@ -1708,11 +1731,12 @@ test "SlidingWindow single append soft wrapped" {
test "SlidingWindow single append reversed soft wrapped" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .reverse, "boo!");
defer w.deinit();
- var t: Terminal = try .init(alloc, .{ .cols = 4, .rows = 5 });
+ var t: Terminal = try .init(io, alloc, .{ .cols = 4, .rows = 5 });
defer t.deinit(alloc);
var s = t.vtStream();
@@ -1747,14 +1771,15 @@ test "SlidingWindow single append reversed soft wrapped" {
test "SlidingWindow append whitespace only node" {
const testing = std.testing;
const alloc = testing.allocator;
+ const io = testing.io;
var w: SlidingWindow = try .init(alloc, .forward, "x");
defer w.deinit();
- var s = try Screen.init(alloc, .{
+ var s = try Screen.init(io, alloc, .{
.cols = 80,
.rows = 24,
- .max_scrollback = 0,
+ .max_scrollback_bytes = 0,
});
defer s.deinit();