summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pardes.zig39
-rw-r--r--test/snapshots/find.golden8
-rw-r--r--test/snapshots/find.snap7
-rw-r--r--test/snapshots/fsearch.golden2
-rw-r--r--test/snapshots/grep.golden16
-rw-r--r--test/snapshots/grep.snap4
-rw-r--r--test/snapshots/psearch.golden8
-rw-r--r--test/snapshots/rsearch.golden42
8 files changed, 75 insertions, 51 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index 9b21ec79..0c7c0363 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -3857,15 +3857,29 @@ pub const Pardes = struct {
// still gets its own buffer, and that IS the old rule: two searches are
// two lists, both stay open at their sizes, and the new one stacks
// directly below this pane (placeDoc). Focus stays here either way.
- if (output_pane.resultsFrom(p, pane, from)) {
- const rp = p.panes[pane.search_pane.?].?;
- const rf = &rp.file.?;
- if (std.mem.eql(u8, rf.output.?.arg(), pat)) {
- file_pane.setContent(p, rf, content);
- rf.scroll = 0;
- pane.search_row = anchor;
- return;
- }
+ // ...and it is ANY open list this search already filled, not only the
+ // one n/N are armed on: search `foo`, then `bar`, then `foo` again and
+ // the third search re-arms foo's own buffer rather than opening its
+ // identical twin below it. Same directory only — the rows are written
+ // relative to it, so another dir's list is a different list. Never the
+ // searching pane itself (a `/` inside a +Search writes its own rows).
+ for (p.panes, 0..) |slot, i| {
+ if (i == id) continue;
+ const rp = slot orelse continue;
+ const rf = if (rp.file) |*f| f else continue;
+ const o = rf.output orelse continue;
+ if (!std.meta.eql(o.from, from) or !std.mem.eql(u8, o.arg(), pat)) continue;
+ if (!std.mem.eql(u8, std.fs.path.dirname(rf.path) orelse "", dir)) continue;
+ // a refill that changes NOTHING keeps its place: a right click on
+ // an already-armed word is an `n`, and throwing the list back to
+ // the top only to scroll down to the stepped row is a jump with no
+ // information in it.
+ const same = std.mem.eql(u8, rf.content, content);
+ file_pane.setContent(p, rf, content);
+ if (!same) rf.scroll = 0;
+ pane.search_pane = i;
+ pane.search_row = anchor;
+ return;
}
const free = p.freeSlot() orelse {
p.gpa.free(content);
@@ -3910,7 +3924,12 @@ pub const Pardes = struct {
rp.cur_row = r;
rp.cur_col = 0;
rp.cur_pinned = true;
- rp.ensureCursorVisible();
+ // in view, but WITHOUT scrolloff: a results pane is short, and a
+ // three-row margin on a seven-row one means every single n scrolls the
+ // list out from under the eye. A row already on screen moves nothing.
+ const off = rp.scroll();
+ const last = off + @as(i32, rp.rows) - 1;
+ if (r < off) rp.scrollBy(r - off) else if (r > last) rp.scrollBy(r - last);
const ln = modal.lineSlice(rf.content, @intCast(step));
// Both arms are the BUILTIN, run on the results pane — the same call a
// middle or right click on that row would make, so a stepped row and a
diff --git a/test/snapshots/find.golden b/test/snapshots/find.golden
index 8b823866..ed7c5cdc 100644
--- a/test/snapshots/find.golden
+++ b/test/snapshots/find.golden
@@ -323,9 +323,9 @@
|
|
| /tmp/pardes-snap/find/cwd/+Search Del
+| 1 sub/ZQMARK-beta.txt
| 2 sub/nest/zqmark-gamma.txt
| 3 zqmark-alpha.txt
-| 4
== snap back grid=120x40 cursor=7,2
|Kill Newcol Tutor Debug NextColor Dump Find Grep Help
| /tmp/pardes-snap/find/cwd/here.txt Save Del /tmp/pardes-snap/find/cwd Del
@@ -493,8 +493,8 @@
== snap refit grid=120x40 cursor=7,2
|Kill Newcol Tutor Debug NextColor Dump Find Grep Help
| /tmp/pardes-snap/find/cwd/here.txt Save Del /tmp/pardes-snap/find/cwd Del
-|╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
-| /tmp/pardes-snap/find/cwd/+Search Del here.txt other.txt sub zqmark-alpha.txt
+| 1 Find
+| here.txt other.txt sub zqmark-alpha.txt
| /tmp/pardes-snap/find/cwd/+Search Del
| 1
| /tmp/pardes-snap/find/cwd/zqmark-alpha.txt Save Del
@@ -535,7 +535,7 @@
|Kill Newcol Tutor Debug NextColor Dump Find Grep Help
| /tmp/pardes-snap/find/cwd/here.txt Save Del /tmp/pardes-snap/find/cwd Del
| 1 Find
-| /tmp/pardes-snap/find/cwd/+Search Del here.txt other.txt sub zqmark-alpha.txt
+| here.txt other.txt sub zqmark-alpha.txt
| /tmp/pardes-snap/find/cwd/+Search Del
| 1
| /tmp/pardes-snap/find/cwd/zqmark-alpha.txt Save Del
diff --git a/test/snapshots/find.snap b/test/snapshots/find.snap
index 5a4d6a38..c1467d89 100644
--- a/test/snapshots/find.snap
+++ b/test/snapshots/find.snap
@@ -78,8 +78,11 @@ stable 700 10000
key n
stable 400 5000
snap nomatch
-# ... and it grows BACK when the next search finds more: the refit trades rows
-# with the neighbour in both directions, so three hits are three rows again
+# ... and asking for `zqm` AGAIN re-arms the list it ALREADY filled instead of
+# stacking an identical twin under the empty one — even though n/N were armed
+# on the zzqq list, so the reuse is by what a buffer HOLDS (this search, this
+# pattern, this directory), not by which one the pane happens to point at. The
+# frame is therefore the `results` frame unchanged, down to the byte.
key space
key f
key f
diff --git a/test/snapshots/fsearch.golden b/test/snapshots/fsearch.golden
index 8f98c64d..25c9340f 100644
--- a/test/snapshots/fsearch.golden
+++ b/test/snapshots/fsearch.golden
@@ -212,9 +212,9 @@
|
|
| /tmp/pardes-snap/fsearch/cwd/+Search Del
+| 1 g.txt:2:1-4 MARK a
| 2 g.txt:6:1-4 MARK b
| 3 g.txt:10:1-4 MARK c
-| 4
== snap back grid=180x30 cursor=10,7
|Kill Newcol Tutor Debug NextColor Dump Find Grep Help
| /tmp/pardes-snap/fsearch/cwd/g.txt Save Del /tmp/pardes-snap/fsearch/cwd Del /tmp/pardes-snap/fsearch/cwd Del
diff --git a/test/snapshots/grep.golden b/test/snapshots/grep.golden
index 78e7c21c..c913a0ac 100644
--- a/test/snapshots/grep.golden
+++ b/test/snapshots/grep.golden
@@ -150,9 +150,9 @@
|
|
| /tmp/pardes-snap/grep/cwd/+Search Del
+| 1 a.txt:1:7-12 hello TARGET one
| 2 a.txt:3:6-11 last TARGET line
| 3 sub/b.txt:2:1-6 TARGET inside sub
-| 4
== snap nomatch grid=180x30 cursor=17,4
|Kill Newcol Tutor Debug NextColor Dump Find Grep Help
| /tmp/pardes-snap/grep/cwd/a.txt Save Del /tmp/pardes-snap/grep/cwd Del /tmp/pardes-snap/grep/cwd Del
@@ -181,9 +181,9 @@
|
|
| /tmp/pardes-snap/grep/cwd/+Search Del
+| 1 a.txt:1:7-12 hello TARGET one
| 2 a.txt:3:6-11 last TARGET line
| 3 sub/b.txt:2:1-6 TARGET inside sub
-| 4
== snap chordsel grid=180x30 cursor=19,2
|Kill Newcol Tutor Debug NextColor Dump Find Grep Help
| /tmp/pardes-snap/grep/cwd/a.txt Save Del /tmp/pardes-snap/grep/cwd Del /tmp/pardes-snap/grep/cwd Del
@@ -212,9 +212,9 @@
|
|
| /tmp/pardes-snap/grep/cwd/+Search Del
+| 1 a.txt:1:7-12 hello TARGET one
| 2 a.txt:3:6-11 last TARGET line
| 3 sub/b.txt:2:1-6 TARGET inside sub
-| 4
== snap chord grid=180x30 cursor=19,2
|Kill Newcol Tutor Debug NextColor Dump Find Grep Help
| /tmp/pardes-snap/grep/cwd/a.txt Save Del /tmp/pardes-snap/grep/cwd Del /tmp/pardes-snap/grep/cwd Del
@@ -224,10 +224,10 @@
|
|
| a.txt
-| /tmp/pardes-snap/grep/cwd/+Search Del
-| 1 a.txt:1:7-12 hello TARGET one
-| 2 a.txt:3:6-11 last TARGET line
-| 3 sub/b.txt:2:1-6 TARGET inside sub
+|
+|
+|
+|
| /tmp/pardes-snap/grep/cwd/+Search Del
| 1
| /tmp/pardes-snap/grep/cwd/sub/b.txt Save Del
@@ -243,6 +243,6 @@
|
|
| /tmp/pardes-snap/grep/cwd/+Search Del
+| 1 a.txt:1:7-12 hello TARGET one
| 2 a.txt:3:6-11 last TARGET line
| 3 sub/b.txt:2:1-6 TARGET inside sub
-| 4
diff --git a/test/snapshots/grep.snap b/test/snapshots/grep.snap
index af05f2d8..f83b1fba 100644
--- a/test/snapshots/grep.snap
+++ b/test/snapshots/grep.snap
@@ -75,7 +75,9 @@ stable 400 5000
snap nomatch
# the acme chord: a builtin executed with a SELECTION held takes it as the
# argument, so dragging over `TARGET` in a.txt and then clicking Grep runs the
-# walk on that word at once — no tag input, nothing typed
+# walk on that word at once — no tag input, nothing typed. TARGET already has
+# a list open from above, so this refills THAT one; only the zzqq list below is
+# a second buffer, because only it is a different search.
press left 14 3
drag left 20 3
release left 20 3
diff --git a/test/snapshots/psearch.golden b/test/snapshots/psearch.golden
index bda7af05..64dbb905 100644
--- a/test/snapshots/psearch.golden
+++ b/test/snapshots/psearch.golden
@@ -298,10 +298,10 @@
|
|
|
-| /tmp/pardes-snap/psearch/cwd/+Search Del
-| 1 @p0:2:3-6 x MARK a
-| 2 @p0:4:3-6 x MARK b
-| 3 @p0:6:3-6 x MARK c
+|
+|
+|
+|
| /tmp/pardes-snap/psearch/cwd/+Search Del
| 1
| /tmp/pardes-snap/psearch/cwd/+Search Del
diff --git a/test/snapshots/rsearch.golden b/test/snapshots/rsearch.golden
index d96744ee..b23be1fb 100644
--- a/test/snapshots/rsearch.golden
+++ b/test/snapshots/rsearch.golden
@@ -133,9 +133,9 @@
| code.txt
|
|
-| /tmp/pardes-snap/rsearch/cwd/+Search Del
-| 1 code.txt:1:5-11 run count_x now
-| 2 code.txt:3:1-7 count_x again
+|
+|
+|
| /tmp/pardes-snap/rsearch/cwd/sub/dep.txt Save Del
| 1 d1
| 2 d2
@@ -164,9 +164,9 @@
| code.txt
|
|
-| /tmp/pardes-snap/rsearch/cwd/+Search Del
-| 1 code.txt:1:5-11 run count_x now
-| 2 code.txt:3:1-7 count_x again
+|
+|
+|
| /tmp/pardes-snap/rsearch/cwd/sub/dep.txt Save Del
| 1 d1
| 2 d2
@@ -195,9 +195,9 @@
| code.txt
|
|
-| /tmp/pardes-snap/rsearch/cwd/+Search Del
-| 1 code.txt:1:5-11 run count_x now
-| 2 code.txt:3:1-7 count_x again
+|
+|
+|
| /tmp/pardes-snap/rsearch/cwd/sub/dep.txt Save Del
| 1 d1
| 2 d2
@@ -224,11 +224,11 @@
| 4 pick two words
|
| code.txt
-| /tmp/pardes-snap/rsearch/cwd/+Search Del
-| 1 code.txt:4:1-8 pick two words
-| /tmp/pardes-snap/rsearch/cwd/+Search Del
-| 1 code.txt:1:5-11 run count_x now
-| 2 code.txt:3:1-7 count_x again
+|
+|
+|
+|
+|
| /tmp/pardes-snap/rsearch/cwd/sub/dep.txt Save Del
| 1 d1
| 2 d2
@@ -252,14 +252,14 @@
| 1 run count_x now
| 2 open sub/dep.txt:3 here code.txt sub code.txt sub
| 3 count_x again
-|╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
-| /tmp/pardes-snap/rsearch/cwd/+Search Del
-| 1 code.txt:4:10-14 pick two words code.txt
-| /tmp/pardes-snap/rsearch/cwd/+Search Del
-| 1 code.txt:4:1-8 pick two words
+| 4 pick two words
+|
+| code.txt
+|
+|
+|
| /tmp/pardes-snap/rsearch/cwd/+Search Del
-| 1 code.txt:1:5-11 run count_x now
-| 2 code.txt:3:1-7 count_x again
+| 1 code.txt:4:10-14 pick two words
| /tmp/pardes-snap/rsearch/cwd/sub/dep.txt Save Del
| 1 d1
| 2 d2