mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-24 11:53:09 +00:00
style cleanups
Time for another `make style-all`.
This commit is contained in:
parent
46d86766c4
commit
48d5342601
17 changed files with 99 additions and 86 deletions
|
@ -97,9 +97,10 @@ int autoload_t::load(const wcstring &cmd, bool reload) {
|
|||
// on the main thread.
|
||||
if (!inserted) {
|
||||
// We failed to insert.
|
||||
debug(0, _(L"Could not autoload item '%ls', it is already being autoloaded. "
|
||||
L"This is a circular dependency in the autoloading scripts, please remove it."),
|
||||
cmd.c_str());
|
||||
const wchar_t *fmt =
|
||||
_(L"Could not autoload item '%ls', it is already being autoloaded. "
|
||||
L"This is a circular dependency in the autoloading scripts, please remove it.");
|
||||
debug(0, fmt, cmd.c_str());
|
||||
return 1;
|
||||
}
|
||||
// Try loading it.
|
||||
|
|
|
@ -3046,9 +3046,9 @@ static int disown_job(parser_t &parser, io_streams_t &streams, job_t *j) {
|
|||
// Stopped disowned jobs must be manually signalled; explain how to do so
|
||||
if (job_is_stopped(j)) {
|
||||
killpg(j->pgid, SIGCONT);
|
||||
streams.err.append_format(
|
||||
_(L"%ls: job %d ('%ls') was stopped and has been signalled to continue.\n"),
|
||||
L"disown", j->job_id, j->command_wcstr());
|
||||
const wchar_t *fmt =
|
||||
_(L"%ls: job %d ('%ls') was stopped and has been signalled to continue.\n");
|
||||
streams.err.append_format(fmt, L"disown", j->job_id, j->command_wcstr());
|
||||
}
|
||||
|
||||
if (parser.job_remove(j)) {
|
||||
|
|
|
@ -730,7 +730,7 @@ static bool unary_primary_evaluate(test_expressions::token_t token, const wcstri
|
|||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}; // namespace test_expressions
|
||||
|
||||
/// Evaluate a conditional expression given the arguments. If fromtest is set, the caller is the
|
||||
/// test or [ builtin; with the pointer giving the name of the command. for POSIX conformance this
|
||||
|
|
|
@ -807,7 +807,8 @@ void env_init(const struct config_paths_t *paths /* or NULL */) {
|
|||
// Some `su`s keep $USER when changing to root.
|
||||
// This leads to issues later on (and e.g. in prompts),
|
||||
// so we work around it by resetting $USER.
|
||||
// TODO: Figure out if that su actually checks if username == "root"(as the man page says) or UID == 0.
|
||||
// TODO: Figure out if that su actually checks if username == "root"(as the man page says) or
|
||||
// UID == 0.
|
||||
uid_t uid = getuid();
|
||||
setup_user(uid == 0);
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ struct event_t {
|
|||
/// The type-specific parameter. The int types are one of the following:
|
||||
///
|
||||
/// signal: Signal number for signal-type events.Use EVENT_ANY_SIGNAL to match any signal
|
||||
/// pid: Process id for process-type events. Use EVENT_ANY_PID to match any pid. (Negative values are used for PGIDs).
|
||||
/// job_id: Job id for EVENT_JOB_ID type events
|
||||
/// pid: Process id for process-type events. Use EVENT_ANY_PID to match any pid. (Negative
|
||||
/// values are used for PGIDs). job_id: Job id for EVENT_JOB_ID type events
|
||||
union {
|
||||
int signal;
|
||||
int job_id;
|
||||
|
|
|
@ -2134,7 +2134,6 @@ static void test_complete(void) {
|
|||
complete(L"echo \\$Foo", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
do_test(completions.empty());
|
||||
|
||||
|
||||
// File completions.
|
||||
completions.clear();
|
||||
complete(L"cat test/complete_test/te", &completions, COMPLETION_REQUEST_DEFAULT, vars);
|
||||
|
|
|
@ -41,16 +41,25 @@
|
|||
|
||||
/// The environment variables used to specify the color of different tokens. This matches the order
|
||||
/// in highlight_spec_t.
|
||||
static const wchar_t *const highlight_var[] = {
|
||||
L"fish_color_normal", L"fish_color_error", L"fish_color_command", L"fish_color_end",
|
||||
L"fish_color_param", L"fish_color_comment", L"fish_color_match", L"fish_color_search_match",
|
||||
L"fish_color_operator", L"fish_color_escape", L"fish_color_quote", L"fish_color_redirection",
|
||||
L"fish_color_autosuggestion", L"fish_color_selection",
|
||||
|
||||
L"fish_pager_color_prefix", L"fish_pager_color_completion", L"fish_pager_color_description",
|
||||
L"fish_pager_color_progress", L"fish_pager_color_secondary"
|
||||
|
||||
};
|
||||
static const wchar_t *const highlight_var[] = {L"fish_color_normal",
|
||||
L"fish_color_error",
|
||||
L"fish_color_command",
|
||||
L"fish_color_end",
|
||||
L"fish_color_param",
|
||||
L"fish_color_comment",
|
||||
L"fish_color_match",
|
||||
L"fish_color_search_match",
|
||||
L"fish_color_operator",
|
||||
L"fish_color_escape",
|
||||
L"fish_color_quote",
|
||||
L"fish_color_redirection",
|
||||
L"fish_color_autosuggestion",
|
||||
L"fish_color_selection",
|
||||
L"fish_pager_color_prefix",
|
||||
L"fish_pager_color_completion",
|
||||
L"fish_pager_color_description",
|
||||
L"fish_pager_color_progress",
|
||||
L"fish_pager_color_secondary"};
|
||||
|
||||
/// Determine if the filesystem containing the given fd is case insensitive for lookups regardless
|
||||
/// of whether it preserves the case when saving a pathname.
|
||||
|
@ -843,9 +852,8 @@ void highlighter_t::color_redirection(const parse_node_t &redirection_node) {
|
|||
this->parse_tree.type_for_redirection(redirection_node, this->buff, NULL, &target);
|
||||
|
||||
// We may get a TOK_NONE redirection type, e.g. if the redirection is invalid.
|
||||
this->color_node(
|
||||
*redirection_primitive,
|
||||
redirect_type == TOK_NONE ? highlight_spec_error : highlight_spec_redirection);
|
||||
auto hl = redirect_type == TOK_NONE ? highlight_spec_error : highlight_spec_redirection;
|
||||
this->color_node(*redirection_primitive, hl);
|
||||
|
||||
// Check if the argument contains a command substitution. If so, highlight it as a param
|
||||
// even though it's a command redirection, and don't try to do any other validation.
|
||||
|
@ -942,9 +950,8 @@ void highlighter_t::color_redirection(const parse_node_t &redirection_node) {
|
|||
}
|
||||
|
||||
if (redirection_target != NULL) {
|
||||
this->color_node(
|
||||
*redirection_target,
|
||||
target_is_valid ? highlight_spec_redirection : highlight_spec_error);
|
||||
auto hl = target_is_valid ? highlight_spec_redirection : highlight_spec_error;
|
||||
this->color_node(*redirection_target, hl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,9 +53,9 @@ void io_buffer_t::read() {
|
|||
// never block. But a broken pipe seems to cause some flags to reset, causing the
|
||||
// EOF flag to not be set. Therefore, EAGAIN is ignored and we exit anyway.
|
||||
if (errno != EAGAIN) {
|
||||
debug(1, _(L"An error occured while reading output from code block on file "
|
||||
L"descriptor %d"),
|
||||
pipe_fd[0]);
|
||||
const wchar_t *fmt =
|
||||
_(L"An error occured while reading output from code block on fd %d");
|
||||
debug(1, fmt, pipe_fd[0]);
|
||||
wperror(L"io_buffer_t::read");
|
||||
}
|
||||
|
||||
|
|
|
@ -555,8 +555,9 @@ void writembs_check(char *mbs, const char *mbs_name, const char *file, long line
|
|||
tputs(mbs, 1, &writeb);
|
||||
} else {
|
||||
env_var_t term = env_get_string(L"TERM");
|
||||
debug(0, _(L"Tried to use terminfo string %s on line %ld of %s, which is undefined in "
|
||||
L"terminal of type \"%ls\". Please report this error to %s"),
|
||||
mbs_name, line, file, term.c_str(), PACKAGE_BUGREPORT);
|
||||
const wchar_t *fmt =
|
||||
_(L"Tried to use terminfo string %s on line %ld of %s, which is "
|
||||
L"undefined in terminal of type \"%ls\". Please report this error to %s");
|
||||
debug(0, fmt, mbs_name, line, file, term.c_str(), PACKAGE_BUGREPORT);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -767,10 +767,11 @@ parse_execution_result_t parse_execution_context_t::handle_command_not_found(
|
|||
}
|
||||
} else if (wcschr(cmd, L'$') || wcschr(cmd, VARIABLE_EXPAND_SINGLE) ||
|
||||
wcschr(cmd, VARIABLE_EXPAND)) {
|
||||
const wchar_t *msg =
|
||||
_(L"Variables may not be used as commands. In fish, "
|
||||
L"please define a function or use 'eval %ls'.");
|
||||
wcstring eval_cmd = reconstruct_orig_str(cmd_str);
|
||||
this->report_error(statement_node, _(L"Variables may not be used as commands. In fish, "
|
||||
L"please define a function or use 'eval %ls'."),
|
||||
eval_cmd.c_str());
|
||||
this->report_error(statement_node, msg, eval_cmd.c_str());
|
||||
} else if (err_code != ENOENT) {
|
||||
this->report_error(statement_node, _(L"The file '%ls' is not executable by this user"),
|
||||
cmd ? cmd : L"UNKNOWN");
|
||||
|
@ -998,10 +999,10 @@ bool parse_execution_context_t::determine_io_chain(const parse_node_t &statement
|
|||
} else {
|
||||
int old_fd = fish_wcstoi(target.c_str());
|
||||
if (errno || old_fd < 0) {
|
||||
errored =
|
||||
report_error(redirect_node, _(L"Requested redirection to '%ls', which "
|
||||
L"is not a valid file descriptor"),
|
||||
target.c_str());
|
||||
const wchar_t *fmt =
|
||||
_(L"Requested redirection to '%ls', "
|
||||
L"which is not a valid file descriptor");
|
||||
errored = report_error(redirect_node, fmt, target.c_str());
|
||||
} else {
|
||||
new_io.reset(new io_fd_t(source_fd, old_fd, true));
|
||||
}
|
||||
|
|
|
@ -44,6 +44,6 @@ inline bool production_element_is_valid(production_element_t elem) {
|
|||
const production_element_t *production_for_token(parse_token_type_t node_type,
|
||||
const parse_token_t &input1,
|
||||
const parse_token_t &input2, uint8_t *out_tag);
|
||||
}
|
||||
} // namespace parse_productions
|
||||
|
||||
#endif
|
||||
|
|
|
@ -440,9 +440,7 @@ const wchar_t *parser_t::is_function() const {
|
|||
return result;
|
||||
}
|
||||
|
||||
const wchar_t *parser_t::get_function_name() {
|
||||
return this->is_function();
|
||||
}
|
||||
const wchar_t *parser_t::get_function_name() { return this->is_function(); }
|
||||
|
||||
int parser_t::get_lineno() const {
|
||||
int lineno = -1;
|
||||
|
|
|
@ -233,8 +233,7 @@ static void maybe_issue_path_warning(const wcstring &which_dir, const wcstring &
|
|||
debug(0, custom_error_msg.c_str());
|
||||
if (path.empty()) {
|
||||
debug(0, _(L"Unable to locate the %ls directory."), which_dir.c_str());
|
||||
debug(0, _(L"Please set the %ls or HOME environment variable "
|
||||
L"before starting fish."),
|
||||
debug(0, _(L"Please set the %ls or HOME environment variable before starting fish."),
|
||||
xdg_var.c_str());
|
||||
} else {
|
||||
const wchar_t *env_var = using_xdg ? xdg_var.c_str() : L"HOME";
|
||||
|
|
|
@ -597,9 +597,9 @@ int job_reap(bool allow_interactive) {
|
|||
} else {
|
||||
const wcstring job_number_desc =
|
||||
(job_count == 1) ? wcstring() : format_string(L"from job %d, ", j->job_id);
|
||||
fwprintf(stdout, _(L"%ls: Process %d, \'%ls\' %ls\'%ls\' "
|
||||
L"terminated by signal %ls (%ls)"),
|
||||
program_name, p->pid, p->argv0(), job_number_desc.c_str(),
|
||||
const wchar_t *fmt =
|
||||
_(L"%ls: Process %d, \'%ls\' %ls\'%ls\' terminated by signal %ls (%ls)");
|
||||
fwprintf(stdout, fmt, program_name, p->pid, p->argv0(), job_number_desc.c_str(),
|
||||
truncate_command(j->command()).c_str(), sig2wcs(WTERMSIG(p->status)),
|
||||
signal_get_desc(WTERMSIG(p->status)));
|
||||
}
|
||||
|
|
|
@ -447,9 +447,9 @@ static void reader_repaint() {
|
|||
bool focused_on_pager = data->active_edit_line() == &data->pager.search_field_line;
|
||||
size_t cursor_position = focused_on_pager ? data->pager.cursor_position() : cmd_line->position;
|
||||
|
||||
s_write(&data->screen, data->left_prompt_buff, data->right_prompt_buff, full_line, cmd_line->size(),
|
||||
&colors[0], &indents[0], cursor_position, data->current_page_rendering,
|
||||
focused_on_pager);
|
||||
s_write(&data->screen, data->left_prompt_buff, data->right_prompt_buff, full_line,
|
||||
cmd_line->size(), &colors[0], &indents[0], cursor_position,
|
||||
data->current_page_rendering, focused_on_pager);
|
||||
|
||||
data->repaint_needed = false;
|
||||
}
|
||||
|
@ -1603,9 +1603,10 @@ static void reader_interactive_init() {
|
|||
} else {
|
||||
if (check_for_orphaned_process(loop_count, shell_pgid)) {
|
||||
// We're orphaned, so we just die. Another sad statistic.
|
||||
debug(1, _(L"I appear to be an orphaned process, so I am quitting politely. My "
|
||||
L"pid is %d."),
|
||||
(int)getpid());
|
||||
const wchar_t *fmt =
|
||||
_(L"I appear to be an orphaned process, so I am quitting politely. "
|
||||
L"My pid is %d.");
|
||||
debug(1, fmt, (int)getpid());
|
||||
exit_without_destructors(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -1020,23 +1020,27 @@ static screen_layout_t compute_layout(screen_t *s, size_t screen_width,
|
|||
// the right prompt? The issue is resizing: if you resize the window smaller, then the right
|
||||
// prompt will wrap to the next line. This means that we can't go back to the line that we were
|
||||
// on, and things turn to chaos very quickly.
|
||||
size_t calculated_width;
|
||||
bool done = false;
|
||||
|
||||
// Case 1
|
||||
if (!done &&
|
||||
left_prompt_width + right_prompt_width + first_command_line_width +
|
||||
autosuggest_total_width <
|
||||
screen_width) {
|
||||
if (!done) {
|
||||
calculated_width = left_prompt_width + right_prompt_width + first_command_line_width +
|
||||
autosuggest_total_width;
|
||||
if (calculated_width < screen_width) {
|
||||
result.left_prompt = left_prompt;
|
||||
result.left_prompt_space = left_prompt_width;
|
||||
result.right_prompt = right_prompt;
|
||||
result.autosuggestion = autosuggestion;
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Case 2. Note that we require strict inequality so that there's always at least one space
|
||||
// between the left edge and the rprompt.
|
||||
if (!done && left_prompt_width + right_prompt_width + first_command_line_width < screen_width) {
|
||||
if (!done) {
|
||||
calculated_width = left_prompt_width + right_prompt_width + first_command_line_width;
|
||||
if (calculated_width < screen_width) {
|
||||
result.left_prompt = left_prompt;
|
||||
result.left_prompt_space = left_prompt_width;
|
||||
result.right_prompt = right_prompt;
|
||||
|
@ -1045,20 +1049,24 @@ static screen_layout_t compute_layout(screen_t *s, size_t screen_width,
|
|||
size_t available_autosuggest_space =
|
||||
screen_width - (left_prompt_width + right_prompt_width + first_command_line_width);
|
||||
if (autosuggest_total_width > 0 && available_autosuggest_space > 2) {
|
||||
size_t truncation_offset = truncation_offset_for_width(autosuggest_truncated_widths,
|
||||
available_autosuggest_space - 2);
|
||||
size_t truncation_offset = truncation_offset_for_width(
|
||||
autosuggest_truncated_widths, available_autosuggest_space - 2);
|
||||
result.autosuggestion = wcstring(autosuggestion, truncation_offset);
|
||||
result.autosuggestion.push_back(ellipsis_char);
|
||||
}
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Case 3
|
||||
if (!done && left_prompt_width + first_command_line_width < screen_width) {
|
||||
if (!done) {
|
||||
calculated_width = left_prompt_width + first_command_line_width;
|
||||
if (calculated_width < screen_width) {
|
||||
result.left_prompt = left_prompt;
|
||||
result.left_prompt_space = left_prompt_width;
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Case 4
|
||||
if (!done) {
|
||||
|
@ -1072,11 +1080,8 @@ static screen_layout_t compute_layout(screen_t *s, size_t screen_width,
|
|||
prompt_percent_width > 33) {
|
||||
result.prompts_get_own_line = true;
|
||||
}
|
||||
|
||||
done = true;
|
||||
}
|
||||
|
||||
assert(done);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue