diff options
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 29 |
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, |
