fix: opening hunk in EDITOR used wrong line number #375
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.
The file line number that was sent to $EDITOR was relative to the start of the diff text. We now use the parsed hunk header
new_line_start, plus an offset to get to the first edited line in the hunk.This behavior isn't always correct of course, but it's at least better for the common case of viewing a hunk in the diff of the working tree. When viewing a diff of an older commit, the hunk new_line_start doesn't necessarily refer to the correct line in the current code (and the relevant code might no longer exist). In this case, magit will open a buffer (revived from git) which reflects the code at the time of the commit. If you press enter while on a single changed line in the hunk, magit will show you the pre-edit or post-edit version of the code, depending on whether you're on a
-or+diff line, which is pretty fancy.