summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 16:57:01 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:15 -0300
commit68e30f560e46bb9a30433eb23b4edb1b93d69f46 (patch)
tree3f5f3085051488635ec61c02e33062e1eb94bdd7 /src/pardes.zig
parentcd563b1768c688444cc6d172b3679d95b495207c (diff)
downloadpardes-68e30f560e46bb9a30433eb23b4edb1b93d69f46.tar.gz
pardes-68e30f560e46bb9a30433eb23b4edb1b93d69f46.zip
A selection's other ranges live out of line, made at the second range and freed at one
The ranges beside the primary were an inline array in every Text, which at 1024 grew each pane by about 60 KiB. They are now allocated when a second range appears (Text.reserveSels) and given back when the selection is one range again (Text.dropSels); a column's or the workspace's tag allocates from Text.gpa, any other text from its pane's. A refused tag edit restores them by copy. The Pane size budget is back to 128 KiB, and a test holds that a single cursor allocates nothing for them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index 6b397017..187f3ed3 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -4146,6 +4146,8 @@ pub const Pardes = struct {
.pdf_gpa = pdf_gpa,
.tree_sitter_gpa = tree_sitter_gpa,
.opts = opts,
+ .col_tags = @splat(.{ .what = .column, .gpa = gpa }),
+ .global_tag = .{ .what = .workspace, .gpa = gpa },
.fs = .{},
.screen_w = opts.cols,
.screen_h = opts.rows,
@@ -5335,10 +5337,14 @@ pub const Pardes = struct {
if (t.what == .tag and t.mode == .insert and tagline.typedIntoName(p, pane, key)) return;
// A tag's prefix is read-only: a key whose edit reached into it
// changes nothing, not even where the cursor is.
- const kept = .{ t.cur_row, t.cur_col, t.vsel, t.msel, t.sels, t.nsel };
+ const kept = .{ t.cur_row, t.cur_col, t.vsel, t.msel };
+ var kept_sels: [Text.max_selections - 1]Text.SelRange = undefined;
+ const kept_n = t.nsel;
+ @memcpy(kept_sels[0..kept_n], t.sels[0..kept_n]);
t.refused = false;
defer if (t.refused) {
- t.cur_row, t.cur_col, t.vsel, t.msel, t.sels, t.nsel = kept;
+ t.cur_row, t.cur_col, t.vsel, t.msel = kept;
+ t.restoreSels(kept_sels[0..kept_n]);
};
const was = t.mode;
switch (t.mode) {