summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-07-28 12:28:52 -0300
committerGabriel Schneider <[email protected]>2026-08-01 15:02:07 -0300
commit95202b9b22751c86f100aae9ff1c64e535dcbd70 (patch)
treed53dec8f91d67782c3972d59e36ed33be4fbb2d0 /src/pardes.zig
parent2b76b47c8a087b81be139b552d9a41bb2006dcd3 (diff)
downloadpardes-95202b9b22751c86f100aae9ff1c64e535dcbd70.tar.gz
pardes-95202b9b22751c86f100aae9ff1c64e535dcbd70.zip
smal qol ux changes
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index 4d821e60..8e644470 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -2640,8 +2640,10 @@ pub const Pardes = struct {
// a real file names itself; a terminal or an output buffer has no path
const has_path = if (pane.file) |f| !f.output else false;
var idbuf: [16]u8 = undefined;
+ // relative to `dir`, like Find's rows — and `dir` IS this file's
+ // own directory, so that is exactly its basename
const loc: []const u8 = if (has_path)
- pane.file.?.path
+ std.fs.path.basename(pane.file.?.path)
else
std.fmt.bufPrint(&idbuf, "@p{d}", .{id}) catch return;
for (pl.lines, 0..) |ln, i| {
@@ -2663,6 +2665,19 @@ pub const Pardes = struct {
sp.cur_row = 0;
sp.msel.active = false;
pane.search_row = null;
+ // a new result count is a new height (splitBelow does this for a
+ // fresh one): trade rows with the neighbour it was split off, in
+ // BOTH directions so the pane grows back for a wider search. The
+ // neighbour keeps a tag + 2 rows whatever the hit count.
+ if (p.layoutFindTerm(sid)) |loc| if (p.col_n[loc.col] > 1) {
+ p.snapColWeights(loc.col);
+ if (p.panes[p.col_terms[loc.col][if (loc.idx > 0) loc.idx - 1 else 1]]) |sib| {
+ const pair = sp.vweight + sib.vweight;
+ const hi = @max(@as(f32, BOX_H + 1), pair - @as(f32, BOX_H + 2));
+ sp.vweight = @min(hi, @as(f32, @floatFromInt(BOX_H + fileLineCount(std.mem.trimEnd(u8, content, "\n")))));
+ sib.vweight = pair - sp.vweight;
+ }
+ };
return;
};
const free = p.freeSlot() orelse {
@@ -4616,6 +4631,18 @@ pub const Pardes = struct {
};
src.vweight = @floatFromInt(BOX_H + keep);
nw.vweight = @floatFromInt(@max(1, src_h -| (BOX_H + keep)));
+ // an output buffer is worth exactly its own text: a three-hit +Search
+ // is four rows, not half the source. Nothing else can want the rows,
+ // so they go straight back to the pane they were taken from.
+ if (nw.file) |f| if (f.output) {
+ // trimmed: every row ends in a newline, and the empty line after
+ // the last one is not a result
+ const want: f32 = @floatFromInt(BOX_H + fileLineCount(std.mem.trimEnd(u8, f.content, "\n")));
+ if (want < nw.vweight) {
+ src.vweight += nw.vweight - want;
+ nw.vweight = want;
+ }
+ };
}
/// a shell nobody has touched: no typing, cursor on the first prompt line,