summaryrefslogtreecommitdiff
path: root/core/jj.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/jj.zig')
-rw-r--r--core/jj.zig11
1 files changed, 10 insertions, 1 deletions
diff --git a/core/jj.zig b/core/jj.zig
index dea0236f..696bd659 100644
--- a/core/jj.zig
+++ b/core/jj.zig
@@ -2033,8 +2033,17 @@ fn ownerOf(ch: *const Changes, f: *const File.State, row: usize) PinIndex {
/// 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;
+ // No changes shown: the last edit not saved yet is one (POLISH 11:
+ // `]g` and its painted target found nothing in an edited file).
+ if (pane.layers.lanes == 0) {
+ if (f.revision == f.saved_revision) return null;
+ const at = pane.body.last_edit orelse return null;
+ const line: usize = @intCast(@max(0, at.row));
+ if (forward and line > from and line - from <= most) return line;
+ if (!forward and line < from and from - line <= most) return line;
+ return null;
+ }
const ch = answered(p, f.layer.owner) orelse return null;
const n = File.lineCount(f.content);
var row = from;