summaryrefslogtreecommitdiff
path: root/core/Command.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Command.zig')
-rw-r--r--core/Command.zig25
1 files changed, 15 insertions, 10 deletions
diff --git a/core/Command.zig b/core/Command.zig
index 908358de..d0d8d2d3 100644
--- a/core/Command.zig
+++ b/core/Command.zig
@@ -263,14 +263,16 @@ fn matches(q: []const u8, text: []const u8) bool {
return Names.match(q, t, std.ascii.lowerString(&low, t), 0, null, null) != null;
}
-/// The tag's own words, in its order: its text after the prefix but `|`,
-/// then for a terminal `Kill` (its job's), unless the tag has it.
+/// The tag's words, in its order: its computed words, then its own text
+/// but `|` (UX K'1), then for a terminal `Kill` (its job's), unless the
+/// tag has it.
const Words = struct {
- words: std.mem.TokenIterator(u8, .any),
+ computed: std.mem.TokenIterator(u8, .any),
+ own: std.mem.TokenIterator(u8, .any),
kill: bool,
fn next(w: *Words) ?[]const u8 {
- while (w.words.next()) |word| {
+ while (w.computed.next() orelse w.own.next()) |word| {
if (std.mem.eql(u8, word, "|")) continue;
if (std.mem.eql(u8, word, "Kill")) w.kill = false;
return word;
@@ -282,7 +284,7 @@ const Words = struct {
};
fn tagWords(pane: *Pane) Words {
- return .{ .words = std.mem.tokenizeAny(u8, tagline.curTail(pane), " \t\n"), .kill = pane.isTerminal() and pane.command == null };
+ return .{ .computed = std.mem.tokenizeAny(u8, tagline.computedWords(pane), " "), .own = std.mem.tokenizeAny(u8, tagline.curTail(pane), " \t\n"), .kill = pane.isTerminal() and pane.command == null };
}
/// What row `at` of the rows stands for, as Tab writes it: an answer's
@@ -691,6 +693,9 @@ test ": opens a field in the tag after its key cell: the tag's own words first,
defer frame.deinit();
const a = frame.allocator();
const pane = try p.setTestFile("b\na\nc\n");
+ // Typed into: its tag's words Save Undo Del (UX K'3).
+ typeKeys(p, "ix");
+ p.update(.{ .key = .{ .cp = Key.escape } });
const rest = try std.testing.allocator.dupe(u8, try tagOf(p));
defer std.testing.allocator.free(rest);
typeKeys(p, ":");
@@ -699,19 +704,19 @@ test ": opens a field in the tag after its key cell: the tag's own words first,
try std.testing.expectEqual(Prompt.Op.command, s.prompt.op);
try std.testing.expectEqual(panes.Pane.Focus.body, pane.focus);
// The head: its key cell, the field, the count, the hints.
- try std.testing.expect(has(try tagOf(p), ": 16 commands Tab complete · ⏎ run · C-r history · esc"));
+ try std.testing.expect(has(try tagOf(p), ": 14 commands Tab complete · ⏎ run · C-r history · esc"));
// The rows: the tag's words in its order, `in the tag`, the last ruled
// off; then the commands, each what it takes.
try std.testing.expect(has(try bandRow(p, a, 0), "▶ Save "));
try std.testing.expect(has(try bandRow(p, a, 0), "in the tag"));
- try std.testing.expect(has(try bandRow(p, a, 1), " Term "));
+ try std.testing.expect(has(try bandRow(p, a, 1), " Undo "));
// The doc beside them is the current row's: Save's.
try std.testing.expect(has(try bandRow(p, a, 0), "Save in the tag"));
const band = (try Band.of(p, a, pane, p.view().active)).?;
const first = band.steps[0].rows;
- try std.testing.expect(first[4].under and !first[3].under);
- try std.testing.expect(has(first[5].text, "write w"));
- try std.testing.expect(has(first[7].text, "theme") and has(first[7].text, "<theme>"));
+ try std.testing.expect(first[2].under and !first[1].under);
+ try std.testing.expect(has(first[3].text, "write w"));
+ try std.testing.expect(has(first[5].text, "theme") and has(first[5].text, "<theme>"));
// Typing filters both, by the scorer, in their order.
typeKeys(p, "th");
try std.testing.expect(has(try tagOf(p), ": th = Exec th 1 command "));