summaryrefslogtreecommitdiff
path: root/test/panes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 16:12:29 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:15 -0300
commit07a3f53993a27c886ccb3ed665acb9c8b34a2873 (patch)
tree4a4cb5c3c21c7da4989c65a5db0ed01cbb0aa652 /test/panes.zig
parentcc66593d1432813c9af029ce3779ccba9ded8883 (diff)
downloadpardes-07a3f53993a27c886ccb3ed665acb9c8b34a2873.tar.gz
pardes-07a3f53993a27c886ccb3ed665acb9c8b34a2873.zip
A tag's edited text stays alive until the next edit, so ms and md in a tag read it whole
setEditText freed the text a tag edit was handed once it had copied the tag's own part out of it, but every caller reads that text back to place the cursor, and surround goes on to edit it again: ms and md in a tag read freed memory. The same held for a terminal without an edit buffer and a text with no pane. The text is now kept until the next such edit (edit.retireEditText), which covers every caller at once; the callers the audit found reading it back are surround's two, the paste and replace paths, the number adjust, and the insert-mode Enter. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'test/panes.zig')
-rw-r--r--test/panes.zig13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/panes.zig b/test/panes.zig
index 4e98f449..0b9909ad 100644
--- a/test/panes.zig
+++ b/test/panes.zig
@@ -314,6 +314,19 @@ const TagNavigationTests = struct {
try std.testing.expect(pane.prompt == .none and pane.focus == .body);
}
+ test "ms and md edit a tag's own text, and the text the edit made is read back whole" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 20 });
+ defer p.deinit();
+ const pane = try p.setTestFile("body\n");
+ p.update(.tick);
+ key(p, ':'); // the tag, on `Save` the first time
+ for ("miwms(") |cp| key(p, cp);
+ try std.testing.expect(std.mem.indexOf(u8, pardes.tagline.curTail(pane), "(Save)") != null);
+ for ("md(") |cp| key(p, cp);
+ try std.testing.expect(std.mem.indexOf(u8, pardes.tagline.curTail(pane), " Save ") != null);
+ try std.testing.expect(std.mem.indexOf(u8, pardes.tagline.curTail(pane), "(") == null);
+ }
+
test "the keyboard reaches a tag's path, which it can select and yank but not edit" {
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 20 });
defer p.deinit();