fix(core): index moved hunk lines that start with ++ or -- - #867
Open
benvinegar wants to merge 2 commits into
Open
fix(core): index moved hunk lines that start with ++ or --#867benvinegar wants to merge 2 commits into
benvinegar wants to merge 2 commits into
Conversation
collectLineMoveKinds guarded hunk-body +/− lines against looking like +++ b/…/--- a/… file headers, but headers never appear inside a hunk. A content line whose own text starts with ++ (e.g. ++i;, ++ plus) reads as +++… in the patch and was skipped, shifting every later moved-line classification by one row: git's color-moved badges landed on the wrong line and the final moved line lost its badge. Drop both guards; every hunk-body line starting with + or − is content that advances the per-side index. Add regression coverage for both sides.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
Greptile SummaryCorrects moved-line indexing for hunk content beginning with repeated plus or minus characters.
Confidence Score: 5/5The PR appears safe to merge, with focused tests covering both corrected indexing paths. Within a hunk, repeated-sign rows are content rather than file headers, and the collector now advances indices consistently with the parsed addition and deletion arrays. Important Files Changed
Reviews (1): Last reviewed commit: "fix(core): index moved hunk lines that s..." | Re-trigger Greptile |
Member
Author
|
Real terminal captures (tmux panes running the interactive TUI, buggy vs. fixed): https://sideshow.sh/p/2VKXeBS2W-E |
Member
Author
|
The real terminal captures are inline in the PR body above (before/after side by side). |
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.
Before / after
Real terminal captures —
tmuxpanes running Hunk's interactive TUI on the samegit diff --color-moved=zebrainput, buggy code (origin/main) vs. this fix.The moved tint glows on the
++ plusrow before the fix (it was silently dropped from the indexer), and the real moved line+ AAA one…renders as a plain addition. After the fix, the tint sits exactly on the moved line.The hunk adds
++ plusright before a moved line. The classifier indexes every+/-row it sees; the++ plusrow is one of them — but its diff body reads+++, so the old guard treated it as a file header and skipped it, shifting every later classification by one row.Root cause
collectLineMoveKindsguarded hunk-body+/-lines against looking like+++ b/…/--- a/…file headers, but those headers never appear inside a hunk. A content line whose own text starts with++(e.g.++i;,++ plus) reads as+++…in the patch and was skipped, so:--color-movedline lost its "moved" styling, andFix
Removed both guards (
src/core/changeset/fromPatch.ts): inside a hunk, every line starting with+is an added content row and every line starting with-is a deleted content row;inHunkalready excludes the actual headers.Verification
src/core/changeset/fromPatch.test.tsfor both sides (fail on the old code, pass on the fix).bun test src/core/changeset+bun run typecheckgreen.