summaryrefslogtreecommitdiff
path: root/core/Prompt.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Prompt.zig')
-rw-r--r--core/Prompt.zig22
1 files changed, 11 insertions, 11 deletions
diff --git a/core/Prompt.zig b/core/Prompt.zig
index 64e030e0..10886606 100644
--- a/core/Prompt.zig
+++ b/core/Prompt.zig
@@ -809,8 +809,9 @@ pub fn execWord(p: *Pardes, id: usize) void {
/// The span of pane `pane`'s tag its search word takes while its places no
/// longer light it (the first Esc cleared them): drawn dimmed (draw.zig).
pub fn unlit(p: *const Pardes, pane: *Pane) ?[2]usize {
+ if (Trail.outOfRest(p, pane)) return null;
const t = &pane.trail;
- const whole = Trail.folded(p, pane);
+ const whole = Trail.shown_steps;
for (t.steps[0..t.cur], 0..) |*step, i| if (step.* == .search) {
if (lights(pane, &step.search) or t.cur - i > whole) return null;
return t.spanOf(i, whole);
@@ -1056,14 +1057,13 @@ fn strike(p: *Pardes, s: *Surface, pane: *Pane, r: pardes.Rect, line: i32, lo_:
}
}
-/// The head of the prompt's tag: ` s self▌ = Exec Edit x/self/ 4
+/// The head of the prompt's tag: `s self▌ = Exec Edit x/self/ 4
/// selections in 6 lines ⏎ select · M-⏎ as a list · C-r history · esc`.
pub fn head(p: *Pardes, arena: std.mem.Allocator, pane: *Pane) !TagState.Head {
const s = &p.view().tag_state;
const pr = &s.prompt;
var text: std.ArrayList(u8) = .empty;
var spans: std.ArrayList(TagState.Span) = .empty;
- try text.append(arena, ' ');
try styled(arena, &text, &spans, info.get(pr.op).cell, .key);
try text.append(arena, ' ');
const caret: u32 = @intCast(text.items.len + s.field.caret);
@@ -1269,9 +1269,9 @@ test "s asks in the tag's head: its key cell, the field, the plain word and the
try std.testing.expectEqual(TagState.Kind.prompt, p.view().tag_state.kind);
// No chip on the notice band: the prompt is the tag's.
try std.testing.expectEqual(Pane.Prompt.none, pane.prompt);
- try std.testing.expect(std.mem.endsWith(u8, try tagOf(p), " s ⏎ select · M-⏎ as a list · C-r history · esc"));
+ try std.testing.expect(std.mem.endsWith(u8, try tagOf(p), "s ⏎ select · M-⏎ as a list · C-r history · esc"));
typeKeys(p, "self");
- try std.testing.expect(has(try tagOf(p), " s self = Exec Edit x/self/ 2 selections in 3 lines ⏎ select"));
+ try std.testing.expect(has(try tagOf(p), "s self = Exec Edit x/self/ 2 selections in 3 lines ⏎ select"));
try std.testing.expectEqual(@as(u16, 1), pane.body.nsel);
try std.testing.expect(selecting(p, pane).?.dim == false);
// No match: 0, and the selection it began with.
@@ -1310,10 +1310,10 @@ test "Enter keeps what s found, the pattern in / and in the history Up brings ba
typeKeys(p, "K");
p.update(.{ .key = .{ .cp = Key.up } });
try std.testing.expectEqualStrings("self..", p.view().tag_state.field.text());
- try std.testing.expect(has(try tagOf(p), " K self.. = Exec Edit g/self../ keeps 2 of 2"));
+ try std.testing.expect(has(try tagOf(p), "K self.. = Exec Edit g/self../ keeps 2 of 2"));
p.update(.{ .key = .{ .cp = Key.down } });
typeKeys(p, "b");
- try std.testing.expect(has(try tagOf(p), " K b = Exec Edit g/b/ keeps 1 of 2 ⏎ keep"));
+ try std.testing.expect(has(try tagOf(p), "K b = Exec Edit g/b/ keeps 1 of 2 ⏎ keep"));
// Ctrl-r: the history under the tag, a row a line.
p.update(.{ .key = .{ .cp = 'r', .ctrl = true } });
try std.testing.expectEqual(@as(u16, 1), Band.takes(p, p.view().active));
@@ -1325,7 +1325,7 @@ test "Enter keeps what s found, the pattern in / and in the history Up brings ba
typeKeys(p, "|");
try std.testing.expectEqual(Pane.Prompt.none, pane.prompt);
p.update(.{ .key = .{ .cp = 't', .text = "tr a-z A-Z" } });
- try std.testing.expect(has(try tagOf(p), " | tr a-z A-Z = Exec Edit |tr a-z A-Z ⋯ ⏎ replace"));
+ try std.testing.expect(has(try tagOf(p), "| tr a-z A-Z = Exec Edit |tr a-z A-Z ⋯ ⏎ replace"));
p.update(.{ .key = .{ .cp = Key.enter } });
try std.testing.expectEqualStrings("tr a-z A-Z", p.registers.value('|', 0).?);
var asked: ?u32 = null;
@@ -1362,7 +1362,7 @@ test "/ searches the body as it is typed: the current place selected, the gutter
pane.body.cur_row = 2;
pane.body.cur_col = 6;
typeKeys(p, "/dirty");
- try std.testing.expect(has(try tagOf(p), " / dirty = Look /dirty/ 3/7 · 5 lines ⏎ land · M-⏎ as a list"));
+ try std.testing.expect(has(try tagOf(p), "/ dirty = Look /dirty/ 3/7 · 5 lines ⏎ land · M-⏎ as a list"));
try std.testing.expectEqual(@as(?usize, 2), pane.places.current);
try std.testing.expectEqualStrings("▪", try gutterAt(p, frame.allocator(), 0));
try std.testing.expectEqualStrings(" ", try gutterAt(p, frame.allocator(), 1));
@@ -1409,7 +1409,7 @@ test "? searches back from the caret; no match is 0; a pattern that is no regex
pane.body.cur_col = 6;
const was = pane.body.primaryRange(pane.file.?.content, 0);
typeKeys(p, "?dirty");
- try std.testing.expect(has(try tagOf(p), " ? dirty = Look ?dirty? 2/7 · 5 lines ⏎ land"));
+ try std.testing.expect(has(try tagOf(p), "? dirty = Look ?dirty? 2/7 · 5 lines ⏎ land"));
typeKeys(p, "x");
try std.testing.expect(has(try tagOf(p), "= Look ?dirtyx? 0 ⏎ land"));
try std.testing.expectEqualDeep(was, pane.body.primaryRange(pane.file.?.content, 0));
@@ -1497,7 +1497,7 @@ test "a pipe prompt runs a known filter live, a run a selection: the outputs gho
p.update(.{ .key = .{ .cp = Key.enter } });
typeKeys(p, "|");
p.update(.{ .key = .{ .cp = 't', .text = "tr a-z A-Z" } });
- try std.testing.expect(has(try tagOf(p), " | tr a-z A-Z = Exec Edit |tr a-z A-Z ⋯ ⏎ replace"));
+ try std.testing.expect(has(try tagOf(p), "| tr a-z A-Z = Exec Edit |tr a-z A-Z ⋯ ⏎ replace"));
const first = lastPipe(p) orelse return error.MissingLiveRun;
const asked = p.pipe.pipeRequest(first).?;
try std.testing.expectEqual(@as(usize, 2), asked.inputs.len);