Show wrap targets when printing a function

Fixes #1625
This commit is contained in:
ridiculousfish 2019-09-21 12:48:51 -07:00
parent a1f1abc137
commit 95aea7839d

View file

@ -15,6 +15,7 @@
#include "builtin.h"
#include "builtin_functions.h"
#include "common.h"
#include "complete.h"
#include "env.h"
#include "event.h"
#include "fallback.h" // IWYU pragma: keep
@ -136,12 +137,18 @@ static wcstring functions_def(const wcstring &name) {
out.append(L"function ");
// Typically we prefer to specify the function name first, e.g. "function foo --description bar"
// But If the function name starts with a -, we'll need to output it after all the options.
// But if the function name starts with a -, we'll need to output it after all the options.
bool defer_function_name = (name.at(0) == L'-');
if (!defer_function_name) {
out.append(escape_string(name, ESCAPE_ALL));
}
// Output wrap targets.
for (const wcstring &wrap : complete_get_wrap_targets(name)) {
out.append(L" --wraps=");
out.append(escape_string(wrap, ESCAPE_ALL));
}
if (!desc.empty()) {
wcstring esc_desc = escape_string(desc, ESCAPE_ALL);
out.append(L" --description ");