Repository navigation
system/readline: fill in a single match on an empty prefix - #4097
Merged
Merged
Conversation
Contributor
Author
|
The Linux (arm-other) failure is unrelated to this change — it's a defconfig normalization failure in qemu-armv8r-aarch32/nsh, which lives in the nuttx repo and was unnormalized when added (apache/nuttx@6e8eadd6b). Already fixed on nuttx master (apache/nuttx@20a363b94) |
cederom
approved these changes
Nov 20, 2026
Contributor
|
failed jobs restarted :-) |
xiaoxiang781216
approved these changes
Nov 20, 2026
Contributor
|
Please rebase your patch |
Path completion only filled in the sole matching entry when at least
one character of the word was typed, so "cd <TAB>" in a directory
holding a single subdirectory printed the candidate as a list instead
of completing the line. Fill in the match right away, and make a
repeated TAB right after such a fill a no-op when the word is empty
and the previous word already holds the match.
Testing:
- Built with cmake -B build -DBOARD_CONFIG=sim:nsh and
cmake --build build -j, then ran ./build/nuttx.
- In an NSH directory holding one file (only.txt) and one
subdirectory (sub/):
nsh> ls <TAB> fills in "ls only.txt "
nsh> cd <TAB> fills in "cd sub/"
nsh> ls <TAB><TAB> fills once, the second TAB adds nothing
nsh> ls onl<TAB> prefix fills still work as before
- With several matching candidates, "ls a<TAB>" still lists them.
Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
Contributor
Author
done |
Contributor
Author
|
The latest CI run still fails, but the failure is unrelated to this PR. It is caused by a git.sr.ht (sourcehut) outage: the raspberrypi-4b/nxdoom Log: https://github.com/apache/nuttx-apps/actions/runs/44862609825/job/136719692506 |
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.
Summary
Path completion (added by "system/readline: add path completion for
command arguments") only filled in the sole matching entry when at
least one character of the word had been typed. Pressing TAB on an
empty word in a directory with exactly one candidate -- the common
"cd " into a directory that holds a single subdirectory -- always
took the multiple-match branch and printed the candidate as a list
instead of completing the line, even though there was nothing to
choose between.
Fill in a single match right away, regardless of the typed prefix. A
file completion ends in a space, which leaves the word empty again, so
a repeated TAB would match the same file and append it once more; to
keep that from piling up copies, a fill on an empty prefix is skipped
when the previous word on the line already holds the match. Directory
completions end in '/', so the next TAB descends into the directory
and is unaffected.
Impact
directory holds a single matching entry, instead of listing it.
Testing
Built and verified on the sim host target:
NSH session (lines with a leading prompt echo the filled buffer, i.e. what TAB inserted):
Signed-off-by: Junbo Zheng zhengjunbo1@xiaomi.com