diff options
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index 0950d13a..5fdcfe3c 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -4700,10 +4700,18 @@ pub const Pardes = struct { } /// A file pane's path and dot, for the recent list (0 when none). - fn recentDot(pane: *const Pane) ?struct { path: []const u8, line: u32, col: u32 } { + fn recentDot(pane: *const Pane) ?struct { path: []const u8, line: u32, col: u32, aline: u32 = 0, acol: u32 = 0 } { const f = pane.file orelse return null; if (f.output != null) return null; - return .{ .path = f.path, .line = @intCast(@max(0, pane.body.cur_row) + 1), .col = @intCast(@max(0, pane.body.cur_col) + 1) }; + // The selection's anchor too, so a reopen restores both its ends. + const sel = pane.body.vsel.active; + return .{ + .path = f.path, + .line = @intCast(@max(0, pane.body.cur_row) + 1), + .col = @intCast(@max(0, pane.body.cur_col) + 1), + .aline = if (sel) @intCast(@max(0, pane.body.vsel.row) + 1) else 0, + .acol = if (sel) @intCast(@max(0, pane.body.vsel.col) + 1) else 0, + }; } /// The recent entry a closed jump names, by its path's hash. @@ -4714,7 +4722,7 @@ pub const Pardes = struct { pub fn deinit(p: *Pardes) void { // Every file open now is closed with its dot, and the list kept. - for (p.panes) |slot| if (slot) |pane| if (recentDot(pane)) |d| p.recent.closed(p.recentGpa(), d.path, d.line, d.col); + for (p.panes) |slot| if (slot) |pane| if (recentDot(pane)) |d| p.recent.closedSel(p.recentGpa(), d.path, d.line, d.col, d.aline, d.acol); p.saveRecent(); p.recent.deinit(p.recentGpa()); look.cancelLookHover(p); @@ -4827,7 +4835,7 @@ pub const Pardes = struct { fn retirePane(p: *Pardes, pane: *Pane) void { // Closed, a file is remembered with its dot: Recent and a jump back // to it reopen it there. - if (recentDot(pane)) |d| p.recent.closed(p.recentGpa(), d.path, d.line, d.col); + if (recentDot(pane)) |d| p.recent.closedSel(p.recentGpa(), d.path, d.line, d.col, d.aline, d.acol); const watched = (if (pane.file) |f| f.output == null else false) or pane.hasPdf(); for (p.panes, 0..) |slot, id| if (slot == pane) { if (watched) p.emit(.{ .watch = .{ .pane = @intCast(id), .on = false } }); @@ -6694,10 +6702,8 @@ pub const Pardes = struct { // places it, and the entry is that pane from here on. if (j.serial == 0) { const e = p.recentByHash(j.path_hash) orelse return; - var where: [recent_path_cap + 32]u8 = undefined; - const loc = std.fmt.bufPrint(&where, "{s}:{d}:{d}", .{ e.path, @max(1, j.line), @max(1, j.col) }) catch return; const from = p.active; - look.lookAt(p, from, loc); + look.reopenAt(p, from, e.path, .{ .line = @max(1, j.line), .col = @max(1, j.col) }); const opened = p.panes[p.active] orelse return; if (p.active == from) return; p.jumps[@intCast(next)].pane = @intCast(p.active); |
