diff options
Diffstat (limited to 'core/Command.zig')
| -rw-r--r-- | core/Command.zig | 41 |
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); +} |
