mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-13 12:51:15 -03:00
Properly print leading comments and indentation in functions
Store the entire function declaration, not just its job list. This allows us to extract the body of the function complete with any leading comments and indents. Fixes #5285
This commit is contained in:
@@ -331,8 +331,8 @@ eval_result_t parse_execution_context_t::run_begin_statement(tnode_t<g::job_list
|
||||
}
|
||||
|
||||
// Define a function.
|
||||
eval_result_t parse_execution_context_t::run_function_statement(tnode_t<g::function_header> header,
|
||||
tnode_t<g::job_list> body) {
|
||||
eval_result_t parse_execution_context_t::run_function_statement(
|
||||
tnode_t<grammar::block_statement> statement, tnode_t<grammar::function_header> header) {
|
||||
// Get arguments.
|
||||
wcstring_list_t arguments;
|
||||
argument_node_list_t arg_nodes = header.descendants<g::argument>();
|
||||
@@ -343,7 +343,7 @@ eval_result_t parse_execution_context_t::run_function_statement(tnode_t<g::funct
|
||||
}
|
||||
trace_if_enabled(*parser, L"function", arguments);
|
||||
io_streams_t streams(0); // no limit on the amount of output from builtin_function()
|
||||
int err = builtin_function(*parser, streams, arguments, pstree, body);
|
||||
int err = builtin_function(*parser, streams, arguments, pstree, statement);
|
||||
parser->set_last_statuses(statuses_t::just(err));
|
||||
|
||||
wcstring errtext = streams.err.contents();
|
||||
@@ -366,7 +366,7 @@ eval_result_t parse_execution_context_t::run_block_statement(tnode_t<g::block_st
|
||||
} else if (auto header = bheader.try_get_child<g::while_header, 0>()) {
|
||||
ret = run_while_statement(header, contents, associated_block);
|
||||
} else if (auto header = bheader.try_get_child<g::function_header, 0>()) {
|
||||
ret = run_function_statement(header, contents);
|
||||
ret = run_function_statement(statement, header);
|
||||
} else if (auto header = bheader.try_get_child<g::begin_header, 0>()) {
|
||||
ret = run_begin_statement(contents);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user