fix(compact): align zero-width hunk context - #512
Open
caenrique wants to merge 2 commits into
Open
Conversation
esmuellert
requested changes
Aug 2, 2026
| range_end = range_start + 1 | ||
| end | ||
|
|
||
| -- A zero-width range is a boundary between unchanged lines. The formula |
Owner
There was a problem hiding this comment.
The comments seem to be dead and should remove?
esmuellert
added a commit
that referenced
this pull request
Sep 4, 2026
## Summary
Add first-class pull request review by number without checking out a
branch or changing the working tree.
```vim
:CodeDiff pr 512
:CodeDiff pr 512 --remote upstream
:CodeDiff pr 512 --base release/3.x
:CodeDiff pr 512 -- lua/codediff
```
## Changes
- discover and fetch provider pull request refs directly through Git
- GitHub and Azure DevOps: `refs/pull/<number>/{merge,head}`
- GitLab: `refs/merge-requests/<number>/{merge,head}`
- prefer the provider synthetic merge commit so its parents identify the
review base and head
- fall back to the PR head plus the remote default branch, with `--base`
for non-default targets
- support `--remote`, the existing `--repo`/`-C` override, and Git
pathspecs
- keep fetched commits under `refs/codediff/pull-requests/` and
force-update them after PR force-pushes
- add explicit cache cleanup commands:
- `:CodeDiff pr clean <number>`
- `:CodeDiff pr clean --all`
- both support repository selection; cleanup can be scoped with
`--remote`
- separate atomic Git operations from provider-specific pull request
orchestration
- document the command, ref lifecycle, supported providers, and cleanup
behavior
## Benefits
- review a PR from its number with the existing merge-base Explorer
- no checkout, local branch, worktree mutation, provider CLI, or API
token required
- works with existing Git remote authentication, including private
repositories
- supports fork workflows by selecting the target repository remote
- cached refs remain safe for lazy/asynchronous file loading while
remaining explicitly removable
## Testing
- `CODEDIFF_TEST_JOBS=1 ./tests/run_tests.sh` — 108 spec files passed
- pull request integration suite — 12 tests passed against local bare
remotes
- command E2E suite — 24 tests passed
- verified GitHub/Azure DevOps and GitLab ref layouts, merge and head
fallback paths, explicit base selection, non-origin remotes, force-push
updates, pathspecs, invalid/missing PRs, and branch/worktree invariants
- verified targeted cleanup does not remove another PR, remote, or
unrelated `refs/codediff/*` namespace
- mutation-checked provider selection, force-update behavior, merge-base
dispatch, targeted cleanup, and all-ref cleanup
- manually opened GitHub PR #512 end-to-end without checkout
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.
Problem
Compact folds can be off by one after a zero-width hunk, so corresponding fold boundaries do not align between the two panes.
Solution
Handle zero-width ranges as boundaries when calculating visible context, and map the first folded line consistently between both sides.
Testing
Added compact-mode tests for zero-width context and fold alignment. The compact test suite passes.