Skip to content

fix: honor COMP_CWORD in generated completion - #516

Merged
codeforester merged 2 commits into
mainfrom
bug/508-20260917-bug-generate-completion-from-words-through-comp-cword-only
Sep 18, 2026
Merged

codeforester merged 2 commits into
mainfrom
bug/508-20260917-bug-generate-completion-from-words-through-comp-cword-only

Conversation

@codeforester

Copy link
Copy Markdown
Collaborator

Summary

Generate completion input only through the cursor, preserving empty/quoted word boundaries. Keep completion scratch values local while leaving Bash's required COMPREPLY global intact.

Issue

Fixes #508

Validation

  • bats lib/bash/cli/tests/lib_cli.bats — passed (37 tests).
  • git diff --check — passed.
  • Full repository hosted validation is pending.

Demo Impact

None.

Docs Impact

None.

API Impact

No public function signature change; generated completion behavior is corrected.

CI Impact

Adds emitted-function tests for beginning, middle, end, pending-value, nested-command, and -- cursor positions.

Security Notes

None.

Comment thread lib/bash/cli/lib_cli.sh Outdated
@codeforester

Copy link
Copy Markdown
Collaborator Author

Confirmed fixed. Reproduced the exact repro (COMP_WORDS=(probe admin), COMP_CWORD=2, no trailing placeholder) against the new code — COMPREPLY now correctly completes the empty next word instead of re-suggesting "admin". 37/37 tests pass, including a new test covering this exact boundary.

@codeforester
codeforester merged commit a8fc3a6 into main Sep 18, 2026
11 checks passed
@codeforester
codeforester deleted the bug/508-20260917-bug-generate-completion-from-words-through-comp-cword-only branch September 18, 2026 17:16
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.

bug: generate completion from words through COMP_CWORD only

1 participant