diff options
| -rw-r--r-- | core/views.zig | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/core/views.zig b/core/views.zig index 89dcb454..3c2248d7 100644 --- a/core/views.zig +++ b/core/views.zig @@ -324,7 +324,11 @@ pub fn gone(p: *Pardes, id: usize) void { fn park(p: *Pardes) void { for (p.panes) |s| if (s) |pane| { + // The slot owns the live text's selections now: known, so that + // the pane's end or the view's frees them (a pane made while one + // view was open had no view known). pane.pv[p.live] = extract(pane); + pane.pv_known |= bit(p.live); }; } @@ -601,6 +605,25 @@ test "each view has its own cursor and scroll, and an edit in one is in the othe try testing.expectEqual(Text.Mode.normal, pane.body.mode); } +// A pane made while one view is open is its share there alone; the +// ranges beside its primary that a key makes are the live text's, and +// the view's slot owns them once another view is live (park): freed with +// the pane, or with that view. +test "a text's ranges beside its primary, made while one view was open, are freed once another view has been live" { + const gpa = testing.allocator; + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); + defer p.deinit(); + const text = try numbered(gpa, 20); + defer gpa.free(text); + const pane = try p.setTestFile(text); + // A second cursor below, and a key typed in insert mode at both. + typeKeys(p, "Cix"); + escape(p); + try testing.expect(pane.body.sels.len > 0); + try testing.expectEqual(@as(?View.Id, .at(1)), p.openView()); + p.toView(.at(1)); +} + test "each view has its own layout and focus over the same panes" { const gpa = testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 30 }); |
