summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/Kind.zig22
1 files changed, 20 insertions, 2 deletions
diff --git a/core/Kind.zig b/core/Kind.zig
index 9316c502..c8420c8a 100644
--- a/core/Kind.zig
+++ b/core/Kind.zig
@@ -1310,8 +1310,11 @@ var drawn: u32 = 0;
/// its own.
pub fn landDraw(p: *Pardes, j: *host_io.KindJob) void {
if (j.draw != p) return j.drop();
- // Its pane closed meanwhile: no paint of it would ever take it.
- if (if (p.panes[j.pane]) |pane| pane.serial != j.serial else true) return j.drop();
+ // Its pane closed meanwhile, or showing no kind now (a picker's preview
+ // closed, the pane its own text again): no paint of it would ever take
+ // it, nor would the pane's close (Kind.close: a slot's draws).
+ const pane = p.panes[j.pane] orelse return j.drop();
+ if (pane.serial != j.serial or pane.addon == null) return j.drop();
ready.append(heap, j) catch return j.drop();
p.needs_frame = true;
}
@@ -1427,3 +1430,18 @@ const GpuPaint = struct {
return 0;
}
};
+
+test "a picture drawn for a pane that shows no kind's slot when it lands (a picker's preview closed meanwhile) is dropped, never kept for a paint that never comes" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 });
+ defer p.deinit();
+ _ = try p.setTestFile("the notes\n");
+ const id = p.view().active;
+ try std.testing.expect(p.panes[id].?.addon == null);
+ // A draw of the preview's, back from its worker after Esc gave the pane
+ // its own text again.
+ const j = try heap.create(host_io.KindJob);
+ j.* = .{ .gpa = heap, .pane = @intCast(id), .serial = p.panes[id].?.serial, .token = c.PA_DRAWN | 1, .gen = 0, .ops = &test_kind.ops, .in = try heap.dupe(u8, "draw"), .arena = .init(heap), .draw = p };
+ Addon.holdJob(j.ops, true);
+ landDraw(p, j);
+ try std.testing.expectEqual(@as(usize, 0), ready.items.len);
+}