Skip to content

feat(fugitive): line position tracking for keymaps#70

Merged
barrettruth merged 1 commit intomainfrom
feat/hunk-line-position
Feb 5, 2026
Merged

feat(fugitive): line position tracking for keymaps#70
barrettruth merged 1 commit intomainfrom
feat/hunk-line-position

Conversation

@barrettruth
Copy link
Owner

When pressing du/dU from a hunk line in the fugitive status buffer (after expanding with =), the unified diff now opens at the corresponding line instead of line 1.

Before: Cursor always at line 1 of diff buffer
After: Cursor lands on the same line you were viewing in the fugitive status

Implementation:

  • fugitive.get_hunk_position(bufnr, lnum) - returns @@ header and offset when cursor is on a hunk line
  • commands.find_hunk_line(diff_lines, hunk_position) - finds matching @@ header in diff buffer
  • commands.gdiff_file() accepts optional hunk_position and jumps after opening

Also updates @phanen's README credit for the previous two fixes (#68, #69).

Closes #65

When pressing `du`/`dU` from a hunk line in the fugitive status buffer
(after expanding with `=`), the unified diff now opens at the
corresponding line instead of line 1.

Implementation:
- `fugitive.get_hunk_position()` returns @@ header and offset when on a hunk line
- `commands.find_hunk_line()` finds matching @@ header in diff buffer
- `commands.gdiff_file()` accepts optional `hunk_position` and jumps after opening

Also updates @phanen's README credit for the previous two fixes.

Closes #65
@barrettruth barrettruth merged commit 0e6871b into main Feb 5, 2026
7 checks passed
@barrettruth barrettruth deleted the feat/hunk-line-position branch February 5, 2026 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enhancement: line position tracking for fugitive keymaps

1 participant