complete: replace confusing comment with test case

This commit is contained in:
Johannes Altmanninger 2020-01-08 17:53:46 +01:00
parent 75fa3b6bae
commit 9a355d5482
2 changed files with 9 additions and 6 deletions

View file

@ -665,12 +665,7 @@ static wcstring complete_function_desc(const wcstring &fn) {
bool has_description = function_get_desc(fn, result);
if (!has_description) {
function_get_definition(fn, result);
// Consider complete -a '(complete -C "prefix")':
// If some functions whose name starts with prefix and whose
// definition includes a line that starts with prefix, this line
// would be suggested as completion.
// Replace newlines by spaces to avoid these excess lines.
// The completion description will be shown in one line regardless.
// A completion description is a single line.
for (wchar_t &c : result) {
if (c == L'\n') c = L' ';
}

View file

@ -153,3 +153,11 @@ complete -C'function : --arg'
complete -C'echo > /' | string length -q && echo ok
# CHECK: ok
function some_function
echo line1
echo line2
end
complete -c complete_test_function_desc -xa '(complete -Csome_function)'
complete -C'complete_test_function_desc ' | count
# CHECK: 1