Junbo-Zheng opened a new pull request, #4097:
URL: https://github.com/apache/nuttx-apps/pull/4097
## 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 <TAB>" 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
- **Users**: TAB on an empty word now completes directly when the
directory holds a single matching entry, instead of listing it.
- **Build**: None.
- **Hardware**: None.
- **Documentation**: None.
- **Security & Compatibility**: None.
## Testing
Built and verified on the sim host target:
```bash
cmake -B build -DBOARD_CONFIG=sim:nsh -G Ninja
cmake --build build -j
printf 'mkdir /t6\ncd /t6\nmkdir aa\nmkdir ab\necho hi > only.txt\nls \t\nls
a\t\nls aa\t\nls onl\t\nls onl\t\t\ncd \t\ncd \t\npoweroff\n' | ./build/nuttx
```
NSH session (lines with a leading prompt echo the filled buffer, i.e. what
TAB inserted):
```bash
nsh> ls <TAB> -> lists aa, ab, only.txt (multiple matches)
nsh> ls a <TAB> -> lists aa, ab (common prefix already typed)
nsh> ls aa <TAB> -> fills in "ls aa/"
nsh> ls onl <TAB> -> fills in "ls only.txt "
nsh> ls onl <TAB><TAB> -> second TAB adds nothing
nsh> cd <TAB> -> fills in "cd aa/"
nsh> cd <TAB> -> in aa/ (empty): no match, no action
```
Signed-off-by: Junbo Zheng <[email protected]>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]