summaryrefslogtreecommitdiff
path: root/core/Command.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-25 00:52:21 -0300
committerGabriel Schneider <[email protected]>2026-11-25 00:52:21 -0300
commitc9a5d230570863beb8183190d01c7e19c7696a14 (patch)
tree820e6d227dbc49b96850b664704553393129f899 /core/Command.zig
parentac450e5868f528b312abb2b46191cd8bce5bff3d (diff)
downloadpardes-c9a5d230570863beb8183190d01c7e19c7696a14.tar.gz
pardes-c9a5d230570863beb8183190d01c7e19c7696a14.zip
Prompt: `:` has a history of its own, Up and Down recalling the lines its Enter ran and C-r unrolling them before its rows (walk UI, pick-ui SPEC.md §7.2 and §8, item 3 of line E2): Up and Down bring `:`'s ring's lines into the field (Pardes.prompt_history.command, 16 lines, newest first; the search and select prompts' and the pipes' are their own), its rows made again for the line recalled (`set Wrap off` lists Wrap's values); Ctrl-r unrolls the ring as a step, the lines holding the field, now the band's FIRST step for `:` (Prompt.steps): after the rows and their doc it was placed past the doc, which takes the width the others leave, so it was never seen; `:` on the empty field gives the keyboard to the tag's own text and `:` there gives it back (item 1); Esc in a tag keeps today's meaning (Last), as four tests pin it; TEST FIRST: Command.zig ": has a history of its own: Up and Down bring back the lines Enter ran, newest first; C-r unrolls them beside the rows, filtered by the field; a search's lines are not among them" (on item 2: the band's first step was the rows, `Save in the tag` where `goto 2` was looked for); core-test 1023/1190 (167 skipped)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'core/Command.zig')
-rw-r--r--core/Command.zig41
1 files changed, 41 insertions, 0 deletions
diff --git a/core/Command.zig b/core/Command.zig
index 5364b898..4a10e869 100644
--- a/core/Command.zig
+++ b/core/Command.zig
@@ -782,3 +782,44 @@ test ":theme lists the themes and the whole window wears the current one, none d
try std.testing.expect(has(try tagOf(p), " = Look no 1 recent file "));
p.update(.{ .key = .{ .cp = Key.escape } });
}
+
+test ": has a history of its own: Up and Down bring back the lines Enter ran, newest first; C-r unrolls them beside the rows, filtered by the field; a search's lines are not among them" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 40 });
+ defer p.deinit();
+ var frame = std.heap.ArenaAllocator.init(std.testing.allocator);
+ defer frame.deinit();
+ const a = frame.allocator();
+ const pane = try p.setTestFile("one\ntwo\n");
+ const s = &p.view().tag_state;
+ typeKeys(p, ":set Wrap off\r:goto 2\r/one\r");
+ try std.testing.expectEqualStrings("one", p.prompt_history.search.get(1).?);
+ typeKeys(p, ":");
+ p.update(.{ .key = .{ .cp = Key.up } });
+ try std.testing.expectEqualStrings("goto 2", s.field.text());
+ try std.testing.expect(has(try tagOf(p), " : goto 2 = Look :2 <line> "));
+ p.update(.{ .key = .{ .cp = Key.up } });
+ try std.testing.expectEqualStrings("set Wrap off", s.field.text());
+ try std.testing.expectEqual(Rows.values, s.prompt.command.rows);
+ p.update(.{ .key = .{ .cp = Key.up } });
+ try std.testing.expectEqualStrings("set Wrap off", s.field.text());
+ p.update(.{ .key = .{ .cp = Key.down } });
+ p.update(.{ .key = .{ .cp = Key.down } });
+ try std.testing.expectEqualStrings("", s.field.text());
+ try std.testing.expectEqual(Rows.names, s.prompt.command.rows);
+ // C-r: the history beside the rows, its first step, the doc still
+ // in the band's width after them.
+ p.update(.{ .key = .{ .cp = 'r', .ctrl = true } });
+ var band = (try Band.of(p, a, pane, p.view().active)).?;
+ try std.testing.expectEqual(@as(u8, 3), band.nsteps);
+ try std.testing.expectEqualStrings("goto 2", band.steps[0].rows[0].text);
+ try std.testing.expectEqualStrings("set Wrap off", band.steps[0].rows[1].text);
+ try std.testing.expectEqual(@as(usize, 2), band.steps[0].rows.len);
+ try std.testing.expect(band.steps[2].doc and band.steps[2].x < band.columns);
+ // Typed: the history's lines holding it.
+ typeKeys(p, "set");
+ band = (try Band.of(p, a, pane, p.view().active)).?;
+ try std.testing.expectEqual(@as(usize, 1), band.steps[0].rows.len);
+ try std.testing.expectEqualStrings("set Wrap off", band.steps[0].rows[0].text);
+ p.update(.{ .key = .{ .cp = Key.escape } });
+ try std.testing.expectEqual(TagState.Kind.rest, s.kind);
+}