mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-15 23:22:53 +08:00
Restyle
I kinda hate how fussy clang-format is. It reflows text constantly (line limit), forces things onto one line *except* when they're too long, and wants to turn this: ```c++ return true;; ``` into this: ```c++ return true; ; ``` instead of, you know, eliminating the second semicolon? Anyway, it is what it is and we use it, I'll just look into getting some more slack.
This commit is contained in:
parent
69afb1b560
commit
1406d63b85
@ -997,9 +997,7 @@ def get_paths_from_man_locations():
|
||||
def usage(script_name):
|
||||
print(
|
||||
"Usage: {0} [-v, --verbose] [-s, --stdout] [-d, --directory] [-p, --progress]"
|
||||
" [-c, --cleanup-in] [-z] files...".format(
|
||||
script_name
|
||||
)
|
||||
" [-c, --cleanup-in] [-z] files...".format(script_name)
|
||||
)
|
||||
print(
|
||||
"""Command options are:
|
||||
|
@ -77,7 +77,8 @@ function fish_prompt
|
||||
|
||||
# Vi-mode
|
||||
# The default mode prompt would be prefixed, which ruins our alignment.
|
||||
function fish_mode_prompt; end
|
||||
function fish_mode_prompt
|
||||
end
|
||||
if test "$fish_key_bindings" = fish_vi_key_bindings
|
||||
or test "$fish_key_bindings" = fish_hybrid_key_bindings
|
||||
set -l mode
|
||||
|
@ -670,7 +670,8 @@ static bool parse_number(const wcstring &arg, number_t *number, wcstring_list_t
|
||||
// Break the floating point value into base and delta. Ensure that base is <= the floating
|
||||
// point value.
|
||||
//
|
||||
// Note that a non-finite number like infinity or NaN doesn't work for us, so we checked above.
|
||||
// Note that a non-finite number like infinity or NaN doesn't work for us, so we checked
|
||||
// above.
|
||||
double intpart = std::floor(floating);
|
||||
double delta = floating - intpart;
|
||||
*number = number_t{static_cast<long long>(intpart), delta};
|
||||
|
@ -1453,16 +1453,16 @@ static bool unescape_string_internal(const wchar_t *const input, const size_t in
|
||||
switch (c) {
|
||||
case L'\\': {
|
||||
if (!ignore_backslashes) {
|
||||
// Backslashes (escapes) are complicated and may result in errors, or appending
|
||||
// INTERNAL_SEPARATORs, so we have to handle them specially.
|
||||
auto escape_chars = read_unquoted_escape(input + input_position, &result,
|
||||
allow_incomplete, unescape_special);
|
||||
// Backslashes (escapes) are complicated and may result in errors, or
|
||||
// appending INTERNAL_SEPARATORs, so we have to handle them specially.
|
||||
auto escape_chars = read_unquoted_escape(
|
||||
input + input_position, &result, allow_incomplete, unescape_special);
|
||||
if (!escape_chars) {
|
||||
// A none() return indicates an error.
|
||||
errored = true;
|
||||
} else {
|
||||
// Skip over the characters we read, minus one because the outer loop will
|
||||
// increment it.
|
||||
// Skip over the characters we read, minus one because the outer loop
|
||||
// will increment it.
|
||||
assert(*escape_chars > 0);
|
||||
input_position += *escape_chars - 1;
|
||||
}
|
||||
|
@ -119,9 +119,9 @@ enum escape_string_style_t {
|
||||
|
||||
// Flags for unescape_string functions.
|
||||
enum {
|
||||
UNESCAPE_DEFAULT = 0, // default behavior
|
||||
UNESCAPE_SPECIAL = 1 << 0, // escape special fish syntax characters like the semicolon
|
||||
UNESCAPE_INCOMPLETE = 1 << 1, // allow incomplete escape sequences
|
||||
UNESCAPE_DEFAULT = 0, // default behavior
|
||||
UNESCAPE_SPECIAL = 1 << 0, // escape special fish syntax characters like the semicolon
|
||||
UNESCAPE_INCOMPLETE = 1 << 1, // allow incomplete escape sequences
|
||||
UNESCAPE_NO_BACKSLASHES = 1 << 2, // don't handle backslash escapes
|
||||
};
|
||||
typedef unsigned int unescape_flags_t;
|
||||
|
@ -207,20 +207,19 @@ void prettifier_t::prettify_node(const parse_node_tree_t &tree, node_offset_t no
|
||||
if (dump_parse_tree) dump_node(node_indent, node, source);
|
||||
|
||||
// Prepend any escaped newline, but only for certain cases.
|
||||
// We allow it to split arguments (including at the end - this is like trailing commas in lists, makes for better diffs),
|
||||
// to separate pipelines (but it has to be *before* the pipe, so the pipe symbol is the first thing on the new line after the indent)
|
||||
// and to separate &&/|| job lists (`and` and `or` are handled separately below, as they *allow* semicolons)
|
||||
// We allow it to split arguments (including at the end - this is like trailing commas in
|
||||
// lists, makes for better diffs), to separate pipelines (but it has to be *before* the
|
||||
// pipe, so the pipe symbol is the first thing on the new line after the indent) and to
|
||||
// separate &&/|| job lists (`and` and `or` are handled separately below, as they *allow*
|
||||
// semicolons)
|
||||
// TODO: Handle
|
||||
// foo | \
|
||||
// bar
|
||||
// so it just removes the escape - pipes don't need it. This was changed in some fish version, figure out which it was and if
|
||||
// it is worth supporting.
|
||||
if (prev_node_type == symbol_arguments_or_redirections_list
|
||||
|| prev_node_type == symbol_argument_list
|
||||
|| node_type == parse_token_type_andand
|
||||
|| node_type == parse_token_type_pipe
|
||||
|| node_type == parse_token_type_end
|
||||
) {
|
||||
// so it just removes the escape - pipes don't need it. This was changed in some fish
|
||||
// version, figure out which it was and if it is worth supporting.
|
||||
if (prev_node_type == symbol_arguments_or_redirections_list ||
|
||||
prev_node_type == symbol_argument_list || node_type == parse_token_type_andand ||
|
||||
node_type == parse_token_type_pipe || node_type == parse_token_type_end) {
|
||||
maybe_prepend_escaped_newline(node);
|
||||
}
|
||||
|
||||
@ -282,7 +281,9 @@ void prettifier_t::prettify_node(const parse_node_tree_t &tree, node_offset_t no
|
||||
// This can be extended to other characters, but giving the precise list is tough,
|
||||
// can change over time (see "^", "%" and "?", in some cases "{}") and it just makes
|
||||
// people feel more at ease.
|
||||
auto goodchars = [](wchar_t ch) { return fish_iswalnum(ch) || ch == L'_' || ch == L'-' || ch == L'/'; };
|
||||
auto goodchars = [](wchar_t ch) {
|
||||
return fish_iswalnum(ch) || ch == L'_' || ch == L'-' || ch == L'/';
|
||||
};
|
||||
if (std::find_if_not(unescaped.begin(), unescaped.end(), goodchars) ==
|
||||
unescaped.end() &&
|
||||
!unescaped.empty()) {
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <iterator> // for std::begin/end
|
||||
#include <iterator> // for std::begin/end
|
||||
|
||||
static void become_foreground_then_print_stderr() {
|
||||
if (tcsetpgrp(STDOUT_FILENO, getpgrp()) < 0) {
|
||||
|
@ -52,7 +52,8 @@ class category_list_t {
|
||||
category_t debug{L"debug", L"Debugging aid (on by default)", true};
|
||||
|
||||
category_t warning{L"warning", L"Warnings (on by default)", true};
|
||||
category_t warning_path{L"warning-path", L"Warnings about unusable paths for config/history (on by default)", true};
|
||||
category_t warning_path{
|
||||
L"warning-path", L"Warnings about unusable paths for config/history (on by default)", true};
|
||||
|
||||
category_t config{L"config", L"Finding and reading configuration"};
|
||||
|
||||
|
@ -273,7 +273,7 @@ bool is_potential_path(const wcstring &potential_path_fragment, const wcstring_l
|
||||
const wcstring filename_fragment = wbasename(abs_path);
|
||||
if (dir_name == L"/" && filename_fragment == L"/") {
|
||||
// cd ///.... No autosuggestion.
|
||||
return true;;
|
||||
return true;
|
||||
} else if ((dir = wopendir(dir_name))) {
|
||||
cleanup_t cleanup_dir([&] { closedir(dir); });
|
||||
|
||||
|
@ -273,14 +273,16 @@ static void maybe_issue_path_warning(const wcstring &which_dir, const wcstring &
|
||||
FLOG(error, custom_error_msg.c_str());
|
||||
if (path.empty()) {
|
||||
FLOGF(warning_path, _(L"Unable to locate the %ls directory."), which_dir.c_str());
|
||||
FLOGF(warning_path, _(L"Please set the %ls or HOME environment variable before starting fish."),
|
||||
FLOGF(warning_path,
|
||||
_(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";
|
||||
FLOGF(warning_path, _(L"Unable to locate %ls directory derived from $%ls: '%ls'."),
|
||||
which_dir.c_str(), env_var, path.c_str());
|
||||
FLOGF(warning_path, _(L"The error was '%s'."), std::strerror(saved_errno));
|
||||
FLOGF(warning_path, _(L"Please set $%ls to a directory where you have write access."), env_var);
|
||||
FLOGF(warning_path, _(L"Please set $%ls to a directory where you have write access."),
|
||||
env_var);
|
||||
}
|
||||
ignore_result(write(STDERR_FILENO, "\n", 1));
|
||||
}
|
||||
|
@ -323,15 +323,18 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const *
|
||||
if (arg_max > 0) {
|
||||
if (sz >= static_cast<unsigned long long>(arg_max)) {
|
||||
format_size_safe(sz2, static_cast<unsigned long long>(arg_max));
|
||||
debug_safe(0,
|
||||
"The total size of the argument and environment lists %s exceeds the "
|
||||
"operating system limit of %s.",
|
||||
sz1, sz2);
|
||||
debug_safe(
|
||||
0,
|
||||
"The total size of the argument and environment lists %s exceeds the "
|
||||
"operating system limit of %s.",
|
||||
sz1, sz2);
|
||||
} else {
|
||||
// MAX_ARG_STRLEN, a linux thing that limits the size of one argument. It's defined in binfmt.h, but
|
||||
// we don't want to include that just to be able to print the real limit.
|
||||
// MAX_ARG_STRLEN, a linux thing that limits the size of one argument. It's
|
||||
// defined in binfmt.h, but we don't want to include that just to be able to
|
||||
// print the real limit.
|
||||
debug_safe(0,
|
||||
"One of your arguments exceeds the operating system's argument length limit.");
|
||||
"One of your arguments exceeds the operating system's argument "
|
||||
"length limit.");
|
||||
}
|
||||
} else {
|
||||
debug_safe(0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user