summaryrefslogtreecommitdiff
path: root/src/look.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/look.zig')
-rw-r--r--src/look.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/look.zig b/src/look.zig
index 41cfdc0c..6ba6a8d0 100644
--- a/src/look.zig
+++ b/src/look.zig
@@ -1869,6 +1869,18 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void {
const before = p.active;
var opened: ?usize = null;
if (!focusPaneByPath(p, target.path, target.at)) {
+ // A .diff or .patch looked at bare: its hunks stacked in a
+ // +Diff (DiffLook hunks), which takes the keyboard as the
+ // file would; one with none in it opens as text.
+ if (p.settings.diff_look == .hunks and !p.look_text and target.at.line == 0 and
+ (std.mem.endsWith(u8, target.path, ".diff") or std.mem.endsWith(u8, target.path, ".patch")))
+ if (filesystem.read(p, target.path)) |bytes| {
+ defer p.gpa.free(bytes);
+ if (panes.Output.openDiff(p, id, target.path, bytes)) |hid| {
+ p.active = hid;
+ return;
+ } else |_| {}
+ } else |_| {};
const free = p.freeSlot() orelse return p.reportError(id, "look", error.NoPaneSlots);
const nt = panes.File.open(p, free, target.path, target.at.line) catch |err|
return lookOpenFailed(p, id, target.path, err);