Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle range-diff commit header lines in s:cfile() #2353

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zivarah
Copy link

@zivarah zivarah commented Nov 5, 2024

While range-diff output doesn't display with any syntax highlighting, it's still in a buffer with a filetype of 'git' and thus fugitive attaches the standard jump mappings. However, those mappings work inconsistently for range-diff output due to some accidental matching in s:cfile(). For lines like these:

1:  aaaaaaa = 1:  bbbbbbb My subject
2:  aaaaaaa = -:  ------- My other subject

Depending on the position of the cursor, we sometimes hit the <cword> fallback and open the commit. This can happen when the cursor is over a commit hash, or even on one of the :. However, for a line like this:

-:  ------- > 2:  aaaaaaa My subject

We end up hitting the block intended to catch +/- lines in diff output, and fail to identify a commit.

Add a special set of handling for range-diff header lines. In cases where only one commit is present in the line, open that commit automatically regardless of cursor position. For cases where the line represents a different commit on each side, fall back to a <cword> approach to allow opening either commit based on cursor position.

While `range-diff` output doesn't display with any syntax highlighting,
it's still in a buffer with a filetype of 'git' and thus fugitive
attaches the standard jump mappings. However, those mappings work
inconsistently for `range-diff` output due to some accidental matching
in `s:cfile()`. For lines like these:

    1:  aaaaaaa = 1:  bbbbbbb My subject
    2:  aaaaaaa = -:  ------- My other subject

Depending on the position of the cursor, we sometimes hit the `<cword>`
fallback and open the commit. This can happen when the cursor is over a
commit hash, or even on one of the `:`. However, for a line like this:

    -:  ------- > 2:  aaaaaaa My subject

We end up hitting the block intended to catch +/- lines in diff output,
and fail to identify a commit.

Add a special set of handling for range-diff header lines. In cases
where only one commit is present in the line, open that commit
automatically regardless of cursor position. For cases where the line
represents a different commit on each side, fall back to a `<cword>`
approach to allow opening either commit based on cursor position.
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.

1 participant