mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-23 08:31:16 -03:00
Simplify function_info_t and function_data_t
Work towards cleaning up function definition. Migrate inherit_vars into props and capture their values at the point of definition.
This commit is contained in:
@@ -253,17 +253,26 @@ int builtin_function(parser_t &parser, io_streams_t &streams, const wcstring_lis
|
||||
}
|
||||
|
||||
// We have what we need to actually define the function.
|
||||
auto props = std::make_shared<function_properties_t>();
|
||||
props->shadow_scope = opts.shadow_scope;
|
||||
props->named_arguments = std::move(opts.named_arguments);
|
||||
|
||||
// Populate inherit_vars.
|
||||
for (const wcstring &name : opts.inherit_vars) {
|
||||
if (auto var = parser.vars().get(name)) {
|
||||
props->inherit_vars[name] = var->as_list();
|
||||
}
|
||||
}
|
||||
|
||||
props->parsed_source = source;
|
||||
props->body_node = body;
|
||||
|
||||
function_data_t d;
|
||||
d.name = function_name;
|
||||
if (!opts.description.empty()) d.description = opts.description;
|
||||
// d.description = opts.description;
|
||||
d.description = opts.description;
|
||||
d.props = props;
|
||||
d.events = std::move(opts.events);
|
||||
d.props.shadow_scope = opts.shadow_scope;
|
||||
d.props.named_arguments = std::move(opts.named_arguments);
|
||||
d.inherit_vars = std::move(opts.inherit_vars);
|
||||
|
||||
d.props.parsed_source = source;
|
||||
d.props.body_node = body;
|
||||
function_add(std::move(d), parser);
|
||||
|
||||
// Handle wrap targets by creating the appropriate completions.
|
||||
|
||||
Reference in New Issue
Block a user