summaryrefslogtreecommitdiff
path: root/core/jj.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/jj.zig')
-rw-r--r--core/jj.zig27
1 files changed, 21 insertions, 6 deletions
diff --git a/core/jj.zig b/core/jj.zig
index c1d07662..dea0236f 100644
--- a/core/jj.zig
+++ b/core/jj.zig
@@ -2030,14 +2030,15 @@ fn ownerOf(ch: *const Changes, f: *const File.State, row: usize) PinIndex {
/// The line `]g` (`forward`) or `[g` goes to from buffer line `from` of
/// the pane: the next or the previous change's first line (the first of a
/// run of lines one pin wrote or took away: a ghost line is a line); null
-/// with none shown, or none that way.
-pub fn nextChange(p: *Pardes, pane: *const Pane, from: usize, forward: bool) ?usize {
+/// with none shown, or none that way, or none in the `most` lines looked
+/// at (a body's painted targets look at the rows shown alone).
+pub fn nextChange(p: *Pardes, pane: *const Pane, from: usize, forward: bool, most: usize) ?usize {
if (pane.layers.lanes == 0) return null;
const f = if (pane.file) |*file| file else return null;
const ch = answered(p, f.layer.owner) orelse return null;
const n = File.lineCount(f.content);
var row = from;
- while (true) {
+ for (0..most) |_| {
if (forward) {
row += 1;
if (row >= n) return null;
@@ -2048,6 +2049,7 @@ pub fn nextChange(p: *Pardes, pane: *const Pane, from: usize, forward: bool) ?us
const owner = ownerOf(ch, f, row);
if (owner != .none and (row == 0 or ownerOf(ch, f, row - 1) != owner)) return row;
}
+ return null;
}
/// A Look (B3) at column `col` of body row `vr` of pane `id` on the id of
@@ -2534,7 +2536,7 @@ const Repo = struct {
fn told(p: *Pardes, id: usize) []const u8 {
const pane = p.panes[id].?;
- return pane.msg[0..pane.msg_len];
+ return p.messages.saidBy(pane);
}
test "At shows a file at a revision beside it, read-only, coloured as its file; a Look at path@rev:line goes to it; At in it turns it in place; jj's refusals are said" {
@@ -2543,6 +2545,8 @@ test "At shows a file at a revision beside it, read-only, coloured as its file;
defer repo.deinit(gpa);
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 40 });
defer p.deinit();
+ // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6).
+ p.settings.jumps = .@"new-pane";
var line: [4200]u8 = undefined;
p.update(.{ .command = try std.fmt.bufPrint(&line, "Look {s}", .{repo.file}) });
const file = p.view().active;
@@ -2964,6 +2968,8 @@ test "Changes draws what the text has not where it stood, as ghost rows: a line
for ([_]bool{ false, true }) |windowed| {
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 60, .rows = 24, .windowed = windowed });
defer p.deinit();
+ // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6).
+ p.settings.jumps = .@"new-pane";
var line: [4200]u8 = undefined;
p.update(.{ .command = try std.fmt.bufPrint(&line, "Look {s}", .{repo.file}) });
const id = p.view().active;
@@ -3250,6 +3256,8 @@ test "a description is whole, its title and its author never cut: in a pane narr
for ([_]bool{ false, true }) |windowed| {
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 50, .rows = 20, .windowed = windowed });
defer p.deinit();
+ // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6).
+ p.settings.jumps = .@"new-pane";
var line: [4200]u8 = undefined;
p.update(.{ .command = try std.fmt.bufPrint(&line, "Look {s}", .{repo.file}) });
const id = p.view().active;
@@ -3487,6 +3495,8 @@ test "at one place a change's ghost rows come before its description: a line it
defer repo.deinit(gpa);
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 60, .rows = 24, .windowed = false });
defer p.deinit();
+ // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6).
+ p.settings.jumps = .@"new-pane";
var line: [4200]u8 = undefined;
p.update(.{ .command = try std.fmt.bufPrint(&line, "Look {s}", .{repo.file}) });
const pane = p.panes[p.view().active].?;
@@ -3513,6 +3523,8 @@ test "a change the revset does not pin, between two it does, moves the older one
defer repo.deinit(gpa);
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 60, .rows = 24, .windowed = false });
defer p.deinit();
+ // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6).
+ p.settings.jumps = .@"new-pane";
var line: [4200]u8 = undefined;
p.update(.{ .command = try std.fmt.bufPrint(&line, "Look {s}", .{repo.file}) });
const pane = p.panes[p.view().active].?;
@@ -3605,6 +3617,8 @@ test "the layer's lines are the pane's text, read-only: j and k go onto them, a
// query however long the test's directory makes the tags.
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 60, .rows = 44, .windowed = windowed });
defer p.deinit();
+ // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6).
+ p.settings.jumps = .@"new-pane";
var arena: std.heap.ArenaAllocator = .init(gpa);
defer arena.deinit();
const pane = try Lines.open(p, repo.file);
@@ -3656,8 +3670,7 @@ test "the layer's lines are the pane's text, read-only: j and k go onto them, a
// the path there opens it (no selection held: B2 in one runs it).
// (The refusals' words, stacked in the notice band over the body's
// first rows, gone.)
- pane.msg_len = 0;
- pane.msg_older_len = 0;
+ p.messages.live_len = 0;
p.view().active = id;
Lines.at(pane, 0, 0);
p.sync();
@@ -4405,6 +4418,8 @@ test "Compare pins the whole difference between each two points as one change: t
for ([_]bool{ false, true }) |windowed| {
const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 70, .rows = 24, .windowed = windowed });
defer p.deinit();
+ // About a jump opening a pane: `Jumps new-pane` (SPEC §6.6).
+ p.settings.jumps = .@"new-pane";
var line: [4200]u8 = undefined;
p.update(.{ .command = try std.fmt.bufPrint(&line, "Look {s}", .{repo.file}) });
const id = p.view().active;