545e5683
Fix same-row cursor refresh planning
a73x 2026-04-08 18:30
diff --git a/src/main.zig b/src/main.zig index a0b0ab3..413a922 100644 --- a/src/main.zig +++ b/src/main.zig @@ -375,6 +375,8 @@ const RowRefreshState = enum { const CursorRefreshContext = struct { old_row: ?usize, new_row: ?usize, old_col: ?usize, new_col: ?usize, old_visible: bool, new_visible: bool, }; @@ -414,7 +416,9 @@ fn planRowRefresh( } fn cursorNeedsRebuild(cursor: CursorRefreshContext) bool { return cursor.old_row != cursor.new_row or cursor.old_visible != cursor.new_visible; return cursor.old_row != cursor.new_row or cursor.old_col != cursor.new_col or cursor.old_visible != cursor.new_visible; } fn appendCellInstances( @@ -531,6 +535,8 @@ test "planRowRefresh requests full rebuild for full dirty state" { .cursor = .{ .old_row = null, .new_row = null, .old_col = null, .new_col = null, .old_visible = false, .new_visible = false, }, @@ -546,6 +552,8 @@ test "planRowRefresh selects only dirty rows for partial state" { .cursor = .{ .old_row = null, .new_row = null, .old_col = null, .new_col = null, .old_visible = false, .new_visible = false, }, @@ -565,6 +573,8 @@ test "planRowRefresh handles cursor-only updates without unrelated rows" { .cursor = .{ .old_row = 1, .new_row = 2, .old_col = 4, .new_col = 4, .old_visible = true, .new_visible = true, }, @@ -583,6 +593,8 @@ test "planRowRefresh forces full rebuild when dirty rows exceed fixed capacity" .cursor = .{ .old_row = null, .new_row = null, .old_col = null, .new_col = null, .old_visible = true, .new_visible = true, }, @@ -593,6 +605,23 @@ test "planRowRefresh forces full rebuild when dirty rows exceed fixed capacity" try std.testing.expectEqual(@as(usize, 0), plan.rows_to_rebuild.count()); } test "planRowRefresh rebuilds cursor when only column changes on same row" { const plan = planRowRefresh(.partial, &.{ false, false, false }, .{ .cursor = .{ .old_row = 2, .new_row = 2, .old_col = 1, .new_col = 5, .old_visible = true, .new_visible = true, }, }); try std.testing.expect(!plan.full_rebuild); try std.testing.expect(plan.cursor_rebuild); try std.testing.expectEqual(@as(usize, 0), plan.rows_to_rebuild.count()); } fn runDrawSmokeTest(alloc: std.mem.Allocator) !void { var conn = try wayland_client.Connection.init(); defer conn.deinit();