-
Notifications
You must be signed in to change notification settings - Fork 0
fix: preserve completion cursor boundaries #529
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
Merged
codeforester
merged 2 commits into
main
from
bug/527-20260919-bug-preserve-nested-command-completion-at-cursor-end
Sep 30, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Altitude — the code edit is a behavior no-op; it does not deliver the hardening the issue asked for.
Swapping
if ((cursor < word_count)) ... else ...toif ((cursor >= word_count)) ... else ...(with the two branch bodies swapped to match) produces byte-for-byte the same runtime behavior as before, for every value ofcursor/word_count—cursor >= word_countis the exact negation ofcursor < word_count, so branch A and branch B still fire under exactly the same conditions as onmain.Verified empirically: checking out this PR's new
lib_cli.batstests against the pre-PRlib_cli.sh(i.e. reverting only the.shchange, keeping the new regression tests) still passes all 40 tests, including the new cursor-boundary andset -ucases. That confirms the.shchange carries zero behavioral difference — the only thing this PR actually adds is test coverage.Issue #527 explicitly asks for "an implementation shape that cannot lose the empty current word during future completion changes," but the new shape has the identical risk surface as the old one (a future edit can drop the
cli_words+=("")line just as easily in either ordering). The tests are valuable and should be kept, but the.shhunk doesn't structurally reduce the regression risk it claims to close — consider a comment pinning the invariant next to line 1625/1629, or extracting the clamp logic so it can be exercised directly instead of only through the printf-generated string.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in e255cc4. The generated adapter now slices the words once and appends the empty current word under an explicit cursor-at/end invariant, with the invariant documented beside the append. The focused 40-test CLI suite and the full 683-test repository gate pass.