fix(diff): full file context and deleted line parsing#113
Merged
actionshrimp merged 3 commits intomainfrom Feb 24, 2026
Merged
Conversation
Without full-context flag, git only outputs 3 lines of surrounding context per hunk. For longer files this meant the side-by-side diff viewer showed only fragments rather than the complete file. Add -U999999 to all diff source types (staged, unstaged, worktree, commit, range, stash, PR) to match the three-way diffs which already had this fix. Also add is_hunk_boundary post-processing to 2-pane align_sides() so ]c/[c navigation works correctly when hunks merge into one.
The unified diff parser checked for file header patterns (^--- , ^+++ ) before checking if we were inside a hunk. This meant deleted lines whose content started with "-- " (e.g. Lua comments) produced diff lines like "--- comment" that matched the file header pattern and got swallowed instead of being added to the hunk. Same issue for additions starting with "++ ". Fix by checking current_hunk_lines first — if we're inside a hunk, all lines belong to the hunk (only diff --git and @@ can end it).
…ments Add 3 E2E tests covering the bugs fixed in this branch: - Commit diff shows full file content (line10 visible in 20-line file with changes at lines 2 and 19, would be missing without -U999999) - Deleted Lua comment lines appear in commit diff left buffer - Deleted Lua comment lines appear in staged diff left buffer
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
Full file context (
-U999999): The diff viewer was using git's default 3-line context, so longer files only showed fragments around each change. Added-U999999to all diff source types (staged, unstaged, worktree, commit, range, stash, PR) to show the complete file, matching the three-way diffs which already had this. Also addedis_hunk_boundarypost-processing to 2-panealign_sides()so]c/[cnavigation still works when hunks merge.Deleted line parsing bug: The unified diff parser checked for file header patterns (
^---,^+++) before checking if it was inside a hunk. Deleted lines starting with--(e.g. Lua comments) produced diff lines like--- commentthat matched the file header pattern and were silently dropped. Fixed by prioritizing the "inside a hunk" state — onlydiff --gitand@@can exit a hunk, everything else is hunk content.Test plan
-U999999args in all source types (test_diff_source.lua)is_hunk_boundarycontext-to-change transitions (test_diff_content.lua)test_diff_content.lua)-- commentlines not being swallowed (test_diff_hunk.lua)++ ...lines not being swallowed (test_diff_hunk.lua)