summaryrefslogtreecommitdiff
path: root/core/Pick.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Pick.zig')
-rw-r--r--core/Pick.zig31
1 files changed, 31 insertions, 0 deletions
diff --git a/core/Pick.zig b/core/Pick.zig
index 6c86cb98..3bab0970 100644
--- a/core/Pick.zig
+++ b/core/Pick.zig
@@ -1161,6 +1161,9 @@ fn listed(p: *Pardes, pk: *const Pick) void {
var w: Trail.Word = .{ .index = pk.id };
_ = wordOf(p, pk, &w.text);
Trail.through(&pane.trail, .{ .list = w });
+ // The newest list or search is the word n and N walk (SPEC §6.3): a
+ // search's tints go with it (§7.3: lit while it is n's).
+ if (pane.places.provenance == .search) pane.places.clear(p.gpa);
}
/// `n` and `N` in a reading pane whose trail's newest list or search word
@@ -1894,3 +1897,31 @@ test "SPC t t is a picker of the themes in the asking pane's tag, the whole wind
try std.testing.expect(p.theme_preview == null);
try std.testing.expectEqualStrings(themes[shown].name, p.theme().name);
}
+
+test "n and N walk the newest list or search word, or the one Looked at (SPEC §6.3, §7.3): a list landed after a search puts the search's tints out and n walks the list; Look on the search word lights it again and n steps its places" {
+ const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 140, .rows = 40 });
+ defer p.deinit();
+ p.settings.jumps = .walk;
+ const pane = try p.setTestFile("dirty one\nclean\ndirty two\nclean\ndirty three\n");
+ const id = p.view().active;
+ for ("/dirty") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } });
+ p.update(.{ .key = .{ .cp = Key.enter } });
+ try std.testing.expect(pane.places.started);
+ // A list lands in the pane after the search: the list is n's.
+ open(p, id, .list, "Refs", "", "/test.txt:2:1 clean\n/test.txt:4:1 clean\n");
+ landHere(p);
+ try std.testing.expectEqual(id, p.view().active);
+ try std.testing.expectEqual(@as(i32, 1), pane.body.cur_row);
+ try std.testing.expect(!pane.places.started);
+ p.update(.{ .key = .{ .cp = 'n', .text = "n" } });
+ try std.testing.expectEqual(@as(i32, 3), pane.body.cur_row);
+ // Look on the search word: lit again, and n steps its places.
+ var i: u8 = 0;
+ while (i < pane.trail.n and pane.trail.steps[i] != .search) i += 1;
+ try std.testing.expect(i < pane.trail.n);
+ Trail.lookStep(p, id, i);
+ try std.testing.expect(pane.places.started);
+ const was = pane.places.current;
+ p.update(.{ .key = .{ .cp = 'n', .text = "n" } });
+ try std.testing.expect(pane.places.current != null and !std.meta.eql(was, pane.places.current));
+}