You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -302,8 +302,13 @@ The `diff_opts` configuration allows you to customize diff behavior:
302
302
-`open_in_new_tab` (boolean, default: `false`) - Open diffs in a new tab instead of the current tab.
303
303
-`hide_terminal_in_new_tab` (boolean, default: `false`) - When opening diffs in a new tab, do not show the Claude terminal split in that new tab. The terminal remains in the original tab, giving maximum screen estate for reviewing the diff.
304
304
-`on_new_file_reject` ("keep_empty"|"close_window", default: `"keep_empty"`) - Behavior when rejecting a diff for a new file (where the old file did not exist).
305
+
-`auto_resize_terminal` (boolean, default: `true`) - Whether the plugin resizes the Claude terminal across the diff lifecycle. Set to `false` to keep the plugin's hands off the terminal width and manage it yourself via the `ClaudeCodeDiffOpened`/`ClaudeCodeDiffClosed` User autocmds.
305
306
- Legacy aliases (still supported): `vertical_split` (maps to `layout`) and `open_in_current_tab` (inverse of `open_in_new_tab`).
306
307
308
+
Related terminal option: `terminal.diff_split_width_percentage` (number, default: `nil`) shrinks/widens the terminal split while a diff is open, falling back to `terminal.split_width_percentage` when unset. It only applies when `auto_resize_terminal` is `true`.
309
+
310
+
The plugin also emits `User` autocmds `ClaudeCodeDiffOpened` (data: `tab_name`, `file_path`, `new_file_path`, `is_new_file`, `diff_window`, `target_window`, `terminal_window`, `tab_number`) and `ClaudeCodeDiffClosed` (data: `tab_name`, `file_path`, `reason`). These fire regardless of `auto_resize_terminal`, letting user configs react to the diff lifecycle. `reason` is a best-effort human-readable label, not a stable enum; `tab_number` is set only for new-tab diffs and `terminal_window` may be `nil` when no Claude terminal is visible.
311
+
307
312
**Example use case**: If you frequently use `<CR>` or arrow keys in the Claude Code terminal to accept/reject diffs, enable this option to prevent focus from moving to the diff buffer where `<CR>` might trigger unintended actions.
308
313
309
314
```lua
@@ -314,6 +319,7 @@ require("claudecode").setup({
314
319
open_in_new_tab=true, -- Open diff in a separate tab
315
320
hide_terminal_in_new_tab=true, -- In the new tab, do not show Claude terminal
316
321
on_new_file_reject="keep_empty", -- "keep_empty" or "close_window"
322
+
auto_resize_terminal=true, -- false = own terminal width via ClaudeCodeDiffOpened/Closed User autocmds
|`ClaudeCodeDiffOpened`| A proposed-edit diff has opened |`tab_name`, `file_path`, `new_file_path`, `is_new_file`, `diff_window`, `target_window`, `terminal_window`, `tab_number`|
401
+
|`ClaudeCodeDiffClosed`| The diff was accepted/rejected/closed |`tab_name`, `file_path`, `reason`|
402
+
403
+
`reason` is a best-effort, human-readable label (e.g. `"diff accepted"`, `"diff rejected"`, `"replaced by new diff"`); treat it as diagnostic text, not a stable enum to branch on. `tab_number` is only set when the diff opened in its own tab, and `terminal_window` may be `nil` if no Claude terminal is visible.
404
+
405
+
To fully own the terminal width during diffs, set `diff_opts.auto_resize_terminal = false`
406
+
(so the plugin applies no width policy of its own) and resize from the events yourself.
407
+
Note this is "own the width via the events", not "freeze the width": the diff layout still
408
+
runs `wincmd =`, which equalizes splits, so set your desired width in the `ClaudeCodeDiffOpened`
409
+
handler — it fires after the layout is built, so it wins:
0 commit comments