mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 09:12:11 +08:00
Fix function definitions potentially leaking as completions
This commit is contained in:
parent
36693e4391
commit
4c73382231
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user