Repository navigation
WIP: fix #2570 compspec -o fallback semantics in line completion - #2594
Merged
Merged
Conversation
complete_line_candidates_with_dynamic parsed COPT_DIRNAMES / COPT_PLUSDIRS / COPT_DEFAULT / COPT_BASHDEFAULT but never applied their fallback semantics, so a compspec whose function yields an empty COMPREPLY produced zero candidates in the interactive line path. With fzf's -D registration present that blanks TAB completion for every command on unix (niubash#828). GNU ownership, read first-hand in the bash-5.3 tree: - pcomplete.c:1435-1457 gen_compspec_completions: dirnames REPLACES an empty generated result; plusdirs APPENDS directory candidates whenever the dirnames branch did not fire (empty and non-empty results alike), generated via gen_action_completions(CA_DIRECTORY) -> bashline.c:4930 bash_directory_completion_matches, i.e. word-filtered like the CA_DIRECTORY action. - bashline.c:1801-1822 attempt_shell_completion: with the result still empty, COPT_DEFAULT leaves readline's filename completion open and COPT_BASHDEFAULT falls into bash_default_completion (bashline.c:1830): $-variable, ~-username, @-hostname and command-position sets; a plain argument word completes nothing under -o bashdefault alone. The fix mirrors the compgen path's existing dirnames/plusdirs block into the line path (same directory_candidates_matching helper, fallback candidates never -X filtered, never -P/-S wrapped) and materializes the default/bashdefault sets on the still-empty result via two new helpers. Behavior verified against GNU bash 5.3.20 on a real PTY across a 14-case matrix (empty/non-empty x default/bashdefault/dirnames/plusdirs x plain/$/~/@ words). Regression pins: tests/issue2570_compspec_fallback.rs (9 tests: -o default fill, bashdefault plain-empty/$/~ shapes, dirnames fill, plusdirs append + word-filtering, no-option no-fallback, the fzf-shaped -D registration end to end, dirnames-over-default precedence, dirnames non-empty no-fire, default prefix filtering). Guards: 19 completion/compgen targets, 82 passed / 0 failed (issue523 is cfg(windows)-only). Full record in the wave REPORT.md. Refs #2570
caomengxuan666
force-pushed
the
fix/2570-compspec-fallback
branch
from
November 2, 2026 10:11
3e18d01 to
11a8b32
Compare
caomengxuan666
marked this pull request as ready for review
November 2, 2026 10:42
caomengxuan666
added a commit
that referenced
this pull request
Nov 2, 2026
…te helpers (captain integration) The #2575 settings threading changed path_completion_candidates to take &ReadlineCompletionSettings, but the #2594 fallback helpers (directory_candidates_matching / filename_candidates_matching) predated the merge point and kept the old arity, so the combined tree did not compile. Per the #2575 design (apply_completion_actions_with_settings: the line path threads the live readline settings; pcomplete.c's static generators behind the compgen builtin compare with defaults), the line completion callers now pass the live settings and the compgen-builtin callers pass ReadlineCompletionSettings::default(). No behavior change beyond the settings the fallback listings now honor on the line path (hidden-file suppression inside path_completion_candidates).
caomengxuan666
added a commit
that referenced
this pull request
Nov 3, 2026
…ry '/' under filename semantics (captain) The #2621 engine change materializes GNU's rl_filename_completion_desired mark (pcomplete.c:1461-1462) in the candidate list itself, because this engine's list is final for the host. The six fallback pins from #2594 asserted the pre-marking bare contract; they now assert the marked forms, and a new pin covers the -o filenames generator face plus its gating (no option -> bare).
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.
Engine root-cause fix for niubash#828 (TAB completion zero candidates whenever a
complete -Ddefault compspec — e.g. fzf's — yields empty COMPREPLY).What
complete_line_candidates_with_dynamicparsed the compspec-ooptions but never applied their fallback semantics in the interactive line-completion path. This change mirrors the compgen path's dirnames/plusdirs block into the line path and materializes the-o default/-o bashdefaultsets on a still-empty result, in GNU's own layering order.GNU ownership (bash-5.3 tree, read first-hand):
pcomplete.c:1435-1457 gen_compspec_completions: dirnames replaces an empty result; plusdirs appends whenever the dirnames branch did not fire.bashline.c:1801-1822 attempt_shell_completion+bashline.c:1830 bash_default_completion: default = readline filename completion; bashdefault = $-variable / ~-username / @-hostname / command-position sets only (a plain word completes nothing under bashdefault alone).bashline.c:4930 bash_directory_completion_matches: appended directories are word-filtered.Verified against GNU bash 5.3.20 on a real PTY across a 14-case matrix before coding.
Pins & guards
tests/issue2570_compspec_fallback.rs: 9 tests — 9 passed / 0 failed (build slot + scrubbed cargo; corroborated by direct parallel + serial runs of the built binary).#![cfg(windows)], covered by Windows CI); issue1597 included at 14/14.Full record (GNU law, oracle matrix, per-option trigger table, phantom-tally adjudication note, residuals):
~/workspace/rubash-wave-20261102/w15-2570/REPORT.mdin the wave workdir.Residuals: bashdefault's
$(/${command-substitution shapes and glob-pattern words are not materialized; the pre-existing both-required -P/-S wrap condition is untouched.Refs #2570