summaryrefslogtreecommitdiff
path: root/core/look.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/look.zig')
-rw-r--r--core/look.zig19
1 files changed, 12 insertions, 7 deletions
diff --git a/core/look.zig b/core/look.zig
index 6ff1da66..7ca8914f 100644
--- a/core/look.zig
+++ b/core/look.zig
@@ -335,7 +335,7 @@ fn lookFirstHit(p: *Pardes, id: usize) void {
const rp = p.panes[rid] orelse return;
if ((rp.file orelse return).content.len == 0) return;
p.view().active = rid;
- lookWalk(p, 1);
+ lookWalk(p, 1, true);
if (p.view().active != rid) return; // walked out of the list; leave it there
const txt = edit.currentSelText(p, rp) orelse return;
// spent, exactly as the look chord spends it (handleKey)
@@ -546,7 +546,7 @@ pub fn wordSpan(p: ?*pardes.Pardes, word: []const u8, cwd: []const u8, realbuf:
return .{ .start = 0, .end = word.len };
}
-fn lookSpanIn(p: *Pardes, pane: *Pane, from: LookFrom, delta: i32, budget: *usize) ?Pane.LookSpot {
+fn lookSpanIn(p: *Pardes, pane: *Pane, from: LookFrom, delta: i32, budget: *usize, disk: bool) ?Pane.LookSpot {
const lines = edit.paneCursorLines(p.editor(), &pane.body) catch return null;
const nrows: i32 = @intCast(lines.len);
if (nrows == 0) return null;
@@ -562,7 +562,8 @@ fn lookSpanIn(p: *Pardes, pane: *Pane, from: LookFrom, delta: i32, budget: *usiz
if (pane.file) |*f| if (!panes.Output.isWalkRow(f, @intCast(r), ln)) continue;
const on_start = r == start;
switch (grain) {
- .word => {
+ // Which words name a file is the disk's to say.
+ .word => if (disk) {
var best: ?Pane.LookSpot = null;
var i: usize = 0;
while (i < ln.len) {
@@ -577,7 +578,7 @@ fn lookSpanIn(p: *Pardes, pane: *Pane, from: LookFrom, delta: i32, budget: *usiz
if (delta > 0) break; // first one forward; keep the last one back
}
if (best) |b| return b;
- },
+ } else return null,
// one span per row, so there is nothing to keep and nothing to
// scan past: the row either offers it or it does not
.line, .whole => {
@@ -593,7 +594,7 @@ fn lookSpanIn(p: *Pardes, pane: *Pane, from: LookFrom, delta: i32, budget: *usiz
break :span @as(?Span, .{ .start = start_byte, .end = end });
}
};
- break :span lineSpan(p, ln, dir, &realbuf);
+ break :span if (disk) lineSpan(p, ln, dir, &realbuf) else null;
} orelse continue;
const col0: i32 = @intCast(sp.start);
if (lookPast(col0, from, on_start, delta))
@@ -610,7 +611,11 @@ fn commandPaneActive(p: *Pardes) bool {
return pane.command != null and pane.file == null and p.view().header == null;
}
-pub fn lookWalk(p: *Pardes, delta: i32) void {
+/// `disk`: a word or a row with no place of its own is look-able when it
+/// names a file, which the disk says (LookNext, a Look's walk, may wait);
+/// without, only the places the rows hold are (`n` in a kind's pane, a
+/// motion: what it reads is the core's).
+pub fn lookWalk(p: *Pardes, delta: i32, disk: bool) void {
var buf: [MAX_PANES]usize = undefined;
const order = lookWalkPanes(p, &buf);
if (order.len == 0) return;
@@ -628,7 +633,7 @@ pub fn lookWalk(p: *Pardes, delta: i32) void {
// `+ 2 * len` only so the backward subtraction stays unsigned
const idx = (if (delta > 0) at + k else at + 2 * order.len - k) % order.len;
const pane = p.panes[order[idx]] orelse continue;
- if (lookSpanIn(p, pane, from, delta, &budget)) |spot|
+ if (lookSpanIn(p, pane, from, delta, &budget, disk)) |spot|
return landLookSpot(p, order[idx], pane, spot);
if (budget == 0) return; // gave up mid-pane: stay put, stay reversible
from = lookEdge(delta);