diff --git a/src/complete.cpp b/src/complete.cpp index 495bedc9f..c22c8d6e2 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -655,6 +655,15 @@ 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. + for (wchar_t &c : result) { + if (c == L'\n') c = L' '; + } } return result; }