diff options
Diffstat (limited to 'src/builtins.zig')
| -rw-r--r-- | src/builtins.zig | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/builtins.zig b/src/builtins.zig index b2690920..d106330e 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -74,8 +74,7 @@ pub const PaneKind = enum { .image => pane.addon != null, .picture => pane.addon != null or pane.isTerminal(), .program_colors => pane.isTerminal() or (pane.file != null and pane.file.?.pager), - .diff => if (pane.file) |f| pane.colorAlgo() == .diff or - (f.output != null and std.meta.eql(f.output.?.from, panes.Output.Origin{ .cmd = .Diff })) else false, + .diff => @import("hunks.zig").shows(pane), }; } @@ -1094,17 +1093,12 @@ pub const Filter = struct { }; /// Stack a diff's hunks as a diff viewer shows them, each under its place and the declarations around it, in a +Diff; on a +Diff, show the diff itself as text. +/// The diff viewer's one registration: its word and traits here, all else +/// its own (hunks.zig). pub const Diff = struct { pub const needs: PaneKind = .diff; pub const output: OutputTraits = .{ .name = config.diff_buffer, .steps = true, .locations = true }; - pub fn run(c: Ctx) void { - const f = &c.pane.file.?; - if (panes.Output.diffSource(c.p, f)) |source| return panes.Output.showDiffText(c.p, c.id, source); - _ = panes.Output.openDiff(c.p, c.id, f.path, f.content) catch |err| switch (err) { - error.NoHunks => c.p.reportFailure(c.id, "Diff: no hunk in it"), - else => c.p.reportError(c.id, "hunks", err), - }; - } + pub const run = @import("hunks.zig").word; }; /// Cycle the pane's input modes: terminals add raw tty mode to normal/insert. |
