Description
Add a quick way to jump from the diff view to the actual file in the repository at the corresponding line.
Use Cases
- Edit the file: See an issue in diff, jump to file to fix it
- Deeper context: View surrounding code not shown in diff
- Cross-reference: Check how code is used elsewhere
- Quick fixes: Make changes directly while reviewing
Proposed Implementation
Commands
:DiffReviewOpenFile " Open file in new buffer
:DiffReviewOpenFileSplit " Open in split
:DiffReviewOpenFileVsplit " Open in vertical split
Keybindings (in diff window)
gf - Open file at current line (follows Neovim convention)
<C-w>f - Open file in horizontal split
<C-w>gf - Open file in vertical split
gF - Open file at exact line number from diff
Behavior
- Detect current file from diff header
- Map diff line to actual file line number
- Open file and position cursor at corresponding line
- Preserve diff view (don't close review)
Line Number Mapping
For modified lines:
- Added lines (+): Jump to new file line number
- Deleted lines (-): Jump to old file line number (if file still exists)
- Context lines: Jump to current line number
Edge Cases
- File doesn't exist locally (deleted/not checked out): Show error
- Line number out of sync (file changed): Open at approximate location
- Binary files: Open but warn can't position cursor
- New files: Open at line 1
Configuration
require('diff-review').setup({
keymaps = {
diff = {
open_file = 'gf',
open_file_split = '<C-w>f',
open_file_vsplit = '<C-w>gf',
}
}
})
Benefits
- Seamless workflow between review and editing
- Follows Neovim conventions (gf)
- Enables quick fixes during review
- Better understanding of full context
Related
Description
Add a quick way to jump from the diff view to the actual file in the repository at the corresponding line.
Use Cases
Proposed Implementation
Commands
Keybindings (in diff window)
gf- Open file at current line (follows Neovim convention)<C-w>f- Open file in horizontal split<C-w>gf- Open file in vertical splitgF- Open file at exact line number from diffBehavior
Line Number Mapping
For modified lines:
Edge Cases
Configuration
Benefits
Related