Skip to content

Conversation

@andrewbraxton
Copy link
Contributor

Navigation between conflicts does not feel natural.

Namely, the issues are

  • If the cursor is on the start of a conflict (the "<<<<<<<" line), GitConflictNext does not navigate to the next conflict.
  • If the cursor is inside of a conflict (the "content"), and GitConflictPrevious is called, the cursor does not jump to the start of the current conflict (the "<<<<<<<" line).
  • If the cursor is on the first conflict of a file and GitConflictPrevious is called, or the cursor is on the last conflict of a file and GitConflictNext is called, the cursor does not wrap around to the last conflict or first conflict, respectively.

We can resolve these by simplifying the comparator functions in find_next() and find_previous().

  • To find the next conflict, simply find the first conflict whose start is somewhere below the cursor location, iterating in the order the conflicts appear. If one does not exist, use the first conflict in the file, if it exists.
  • To find the previous conflict, simply find the first conflict whose start is somewhere above the cursor location, iterating in the reverse order that the conflicts appear. If one does not exist, use the last conflict in the file, if it exists.

Copy link
Owner

@akinsho akinsho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me 🚀 haven't had the time to test it but will merge and see how people get on with it. Note: will have to revert it if it breaks any workflows

@akinsho akinsho merged commit 701f8ed into akinsho:main Nov 8, 2024
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.

2 participants