feat: add public hunk navigation API - #3
Open
leolaurindo wants to merge 1 commit into
Open
Conversation
Expose change-hunk navigation as a public API instead of forcing users to read the internal prev_hunks state. Adds: - inline-diff.next_hunk() / inline-diff.prev_hunk() Lua functions, jumping the cursor to the next/previous hunk (wrapping at either end) and returning the target line or nil when there are no hunks - :InlineDiffNext / :InlineDiffPrev user commands wrapping the API Includes 7 tests covering next/prev, wrap-around, the no-hunks case, and clamping of deletions at line 0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Expose change-hunk navigation as a public API instead of forcing users to
read the internal prev_hunks state. Adds:
the cursor to the next/previous hunk (wrapping at either end) and
returning the target line or nil when there are no hunks
Includes 7 tests covering next/prev, wrap-around, the no-hunks case, and
clamping of deletions at line 0.
The plugin already computes and stores the current buffer's hnks interally in
prev_hunks. So consumers that want hunk navigation already can do that, but need to access internal state directly (and make a wrap in accessible through init.lua). Navigation depends onWhat I did was to create a set of public functions that provide stable integration without exposing state representation.
next_hunk():prev_hunk()behaves symmetrically and wraps to the final hunk.The commands are thin wrappers around the public API.
Testing
Added tests covering:
Full test suite passes:
Success: 23
Failed: 0
Errors: 0
The combined demo branch is available at:
https://github.com/leolaurindo/inline-diff.nvim/tree/dev/al