diff options
Diffstat (limited to 'src/exec.zig')
| -rw-r--r-- | src/exec.zig | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/src/exec.zig b/src/exec.zig index ee6370bf..35d081fd 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -1201,45 +1201,6 @@ fn columnOf(p: *Pardes, id: usize) usize { return if (layout.findPane(p, id)) |f| f.col else p.view().ncol - 1; } -test "the acme chords act once per selection, not once on the primary" { - const gpa = std.testing.allocator; - const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 30 }); - defer p.deinit(); - while (p.nextEffect()) |_| {} - // Two selections, each naming a DIFFERENT builtin, so what ran is visible - // in the layout rather than in a shell nobody can read from a test. - const pane = try p.setTestFile("Newcol\nNewcol\n"); - const ranges = [_]modal.Selection{ - .{ .anchor = 0, .head = 6 }, - .{ .anchor = 7, .head = 13 }, - }; - pane.body.setRanges(pane.file.?.content, &ranges, &.{}, 0, true); - try std.testing.expectEqual(@as(u16, 1), pane.body.nsel); - - const before = p.view().ncol; - p.update(.{ .key = .{ .cp = Key.tab } }); // config.exec_key: Exec - // BOTH ran. Before this the chord read the primary range and dropped the - // other cursor, so one keystroke over two cursors made one column. - try std.testing.expectEqual(before + 2, p.view().ncol); - // ...and the chord consumed the selection exactly as it does with one. - try std.testing.expectEqual(@as(u16, 0), p.panes[0].?.body.nsel); -} - -test "a switch clicked with a selection held flips unless the selection says on or off" { - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); - defer p.deinit(); - while (p.nextEffect()) |_| {} - const before = p.settings.verbose; - _ = execute(p, p.view().active, withArg(p, "Verbose", "some selected text")); - try std.testing.expectEqual(!before, p.settings.verbose); - _ = execute(p, p.view().active, withArg(p, "Verbose", "on")); - try std.testing.expect(p.settings.verbose); - _ = execute(p, p.view().active, withArg(p, "Verbose", " off\n")); - try std.testing.expect(!p.settings.verbose); - // A word that takes any argument still gets the selection. - try std.testing.expectEqualStrings("Msg some text", withArg(p, "Msg", "some text")); -} - // ---- the words addons bring (Kind.Registry's) ---- /// A line whose first word is an addon's: run, and true; false for one @@ -1288,3 +1249,42 @@ pub fn runWord(p: *Pardes, id: usize, w: *const pardes.Kind.Word, line: []const next.len = @intCast(out.buffered().len); s.values = next; } + +test "the acme chords act once per selection, not once on the primary" { + const gpa = std.testing.allocator; + const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 30 }); + defer p.deinit(); + while (p.nextEffect()) |_| {} + // Two selections, each naming a DIFFERENT builtin, so what ran is visible + // in the layout rather than in a shell nobody can read from a test. + const pane = try p.setTestFile("Newcol\nNewcol\n"); + const ranges = [_]modal.Selection{ + .{ .anchor = 0, .head = 6 }, + .{ .anchor = 7, .head = 13 }, + }; + pane.body.setRanges(pane.file.?.content, &ranges, &.{}, 0, true); + try std.testing.expectEqual(@as(u16, 1), pane.body.nsel); + + const before = p.view().ncol; + p.update(.{ .key = .{ .cp = Key.tab } }); // config.exec_key: Exec + // BOTH ran. Before this the chord read the primary range and dropped the + // other cursor, so one keystroke over two cursors made one column. + try std.testing.expectEqual(before + 2, p.view().ncol); + // ...and the chord consumed the selection exactly as it does with one. + try std.testing.expectEqual(@as(u16, 0), p.panes[0].?.body.nsel); +} + +test "a switch clicked with a selection held flips unless the selection says on or off" { + const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 24 }); + defer p.deinit(); + while (p.nextEffect()) |_| {} + const before = p.settings.verbose; + _ = execute(p, p.view().active, withArg(p, "Verbose", "some selected text")); + try std.testing.expectEqual(!before, p.settings.verbose); + _ = execute(p, p.view().active, withArg(p, "Verbose", "on")); + try std.testing.expect(p.settings.verbose); + _ = execute(p, p.view().active, withArg(p, "Verbose", " off\n")); + try std.testing.expect(!p.settings.verbose); + // A word that takes any argument still gets the selection. + try std.testing.expectEqualStrings("Msg some text", withArg(p, "Msg", "some text")); +} |
