Fix: resolved bug where a local keys array in -ftb-compadd shadowed…
#558
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.
Fix associative subscript completion broken by local
keysshadowingThis PR fixes a long‑standing completion bug in
fzf-tabwhere associative array subscripts could complete to unrelated tokens likePREFIX, even when those are not real keys.Root cause
Inside
-ftb-compadd, we declared a local array namedkeysto capture metadata fields (PREFIX,SUFFIX,IPREFIX,ISUFFIX, etc.) for fzf-tab’s internal completion capture.However, Zsh’s associative subscript completion uses
compadd -a keysand expects akeysarray from the completer context (containing the actual associative keys). Because-ftb-compaddruns in the same dynamic scope, our localkeysshadowed that array. As a result, completion candidates were taken from our internal metadata list, not the real associative keys.Symptom
Example (no
_approximateneeded):Instead of completing to
PLUGIN..., it could insertPREFIXbecause that was one of the internal metadata field names.Fix
Rename the internal array from
keysto_ftb_compcap_keysin-ftb-compaddto avoid the name collision. This restores correct associative key completion without changing any completion logic or behavior for other paths.Compatibility
All existing tests continue to pass.