Skip to content

Commit 2f98b3d

Browse files
committed
feat: Add ++difffold option to GinBuffer
Add ++difffold option to enable automatic folding for file sections in unified diff output. Auto-enable in show action for better navigation of multi-file diffs. Changes: - Add ++difffold option parsing in buffer command - Initialize difffold when ++difffold is present - Auto-enable ++difffold in show action - Update documentation with ++difffold usage examples
1 parent 992b971 commit 2f98b3d

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

denops/gin/action/show.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ async function doShow(
6161
`++opener=${opener}`,
6262
...(emojify ? [`++emojify`] : []),
6363
`++diffjump=${x.commit}`,
64+
`++difffold`,
6465
"show",
6566
x.commit,
6667
]);

denops/gin/command/buffer/command.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export type ExecOptions = {
1212
opener?: string;
1313
emojify?: boolean;
1414
diffjump?: string;
15+
difffold?: boolean;
1516
filetype?: string;
1617
cmdarg?: string;
1718
mods?: string;
@@ -36,6 +37,7 @@ export async function exec(
3637
monochrome: unnullish(options.monochrome, (v) => v ? "" : undefined),
3738
emojify: unnullish(options.emojify, (v) => v ? "" : undefined),
3839
diffjump: options.diffjump,
40+
difffold: unnullish(options.difffold, (v) => v ? "" : undefined),
3941
filetype: options.filetype ?? "gin-buffer",
4042
},
4143
fragment: `${args.join(" ")}$`,

denops/gin/command/buffer/edit.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
} from "../../util/ansi_escape_code.ts";
1818
import { execute } from "../../git/executor.ts";
1919
import { init as initDiffJump } from "../../feat/diffjump/jump.ts";
20+
import { init as initDiffFold } from "../../feat/difffold/fold.ts";
2021

2122
export async function edit(
2223
denops: Denops,
@@ -50,11 +51,16 @@ export async function edit(
5051
emojify: "emojify" in (params ?? {}),
5152
});
5253

53-
// Initialize diff jump functionality if ++jump option is present
54+
// Initialize diff jump functionality if ++diffjump option is present
5455
const jumpCommitish = params?.diffjump;
5556
if (jumpCommitish !== undefined) {
5657
await initDiffJump(denops, bufnr, "buffer");
5758
}
59+
60+
// Initialize diff fold functionality if ++difffold option is present
61+
if ("difffold" in (params ?? {})) {
62+
await initDiffFold(denops, bufnr);
63+
}
5864
}
5965

6066
export type ExecOptions = {

denops/gin/command/buffer/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ async function command(
9898
"opener",
9999
"emojify",
100100
"diffjump",
101+
"difffold",
101102
"filetype",
102103
...builtinOpts,
103104
]);
@@ -108,6 +109,7 @@ async function command(
108109
opener: opts.opener,
109110
emojify: unnullish(opts.emojify, () => true),
110111
diffjump: opts.diffjump,
112+
difffold: unnullish(opts.difffold, () => true),
111113
filetype: opts.filetype,
112114
cmdarg: formatOpts(opts, builtinOpts).join(" "),
113115
mods,

doc/gin.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,15 @@ COMMANDS *gin-commands*
151151
:GinBuffer ++diffjump show HEAD
152152
:GinBuffer ++diffjump=abc123 show abc123
153153
:GinBuffer ++diffjump log -p -1
154+
<
155+
++difffold
156+
Enable automatic folding for file sections in unified diff
157+
output. Each file in the diff will be folded separately,
158+
making it easier to navigate large diffs with multiple files.
159+
For example:
160+
>
161+
:GinBuffer ++difffold show HEAD
162+
:GinBuffer ++diffjump ++difffold log -p -1
154163
<
155164
++filetype={filetype}
156165
Specifies the filetype to set for the buffer. Defaults to

0 commit comments

Comments
 (0)