feat(diff): add layout = "inline" for VS Code-style unified diff#195
Open
zhao-tong wants to merge 2 commits intocoder:mainfrom
Open
feat(diff): add layout = "inline" for VS Code-style unified diff#195zhao-tong wants to merge 2 commits intocoder:mainfrom
zhao-tong wants to merge 2 commits intocoder:mainfrom
Conversation
Add a new inline diff layout that shows deleted (red/strikethrough) and
added (green) lines interleaved in a single read-only buffer, similar to
VS Code's inline diff view. This complements the existing "vertical" and
"horizontal" two-panel diff layouts.
Key changes:
- New `diff_inline.lua` module with pure diff computation, rendering via
extmarks, and resolution/cleanup functions
- Dispatch logic in `diff.lua` routes to inline module when configured
- Config/types updated to accept `layout = "inline"`
- `close_all_diff_tabs` detects inline diff buffers
- Customizable highlight groups: ClaudeCodeInlineDiff{Add,Delete,*Sign}
- Requires Neovim >= 0.9.0 (for vim.diff); base plugin remains 0.8.0+
- 23 new tests covering computation, rendering, MCP responses, cleanup
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- closeAllDiffTabs: call _resolve_diff_as_rejected before cleanup so pending coroutines are properly resumed instead of hanging on yield - closeAllDiffTabs: include resolved diffs in CLOSED_N_DIFF_TABS count - diff_inline: in open_in_new_tab mode, pick editor window from current tab via nvim_tabpage_list_wins instead of global search which could return a window from the original tab - Add tests for new-tab window selection and cleanup - Add nvim_tabpage_list_wins to vim mock Issues found by Codex 5.3 code review. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a new
layout = "inline"option fordiff_optsthat renders a VS Code-style unified inline diff - a single read-only buffer with deleted (red/strikethrough) and added (green) lines interleaved. This complements the existing"vertical"and"horizontal"two-panel diff layouts.Closes #82
Motivation
The existing diff layouts use Neovim's built-in
diffthisto show old and new content side by side. While effective, this uses significant screen real estate with two panels. An inline unified diff provides a more compact view that's familiar to VSCode users, showing changes in context within a single buffer.
Changes
lua/claudecode/diff_inline.lua— self-contained inline diff implementation with:vim.diff()(indices mode)+/-)diff.lua— routes to inline module whenlayout = "inline"is configured; exposes shared utilities asM._members following existing patterns"inline"as a valid layout valueclose_all_diff_tabs— detects inline diff buffers viaclaudecode_inline_diffbuffer variablevim.diffmock with LCS-based hunk computation totests/mocks/vim.luaConfiguration
Highlight groups are customizable:
Requirements
Design Decisions
Test Plan