From 6deef37c6664d1d54752590dbcdc8701f1865868 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sun, 8 Mar 2020 20:25:12 +0100 Subject: [PATCH] fish_indent: Add more acceptable chars for unquoted words This adds "_", "-" and "/" as characters for words we strip quotes from. The list is admittedly a tad arbitrary. --- src/fish_indent.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/fish_indent.cpp b/src/fish_indent.cpp index a9d05f024..6c1a45a8d 100644 --- a/src/fish_indent.cpp +++ b/src/fish_indent.cpp @@ -263,10 +263,14 @@ void prettifier_t::prettify_node(const parse_node_tree_t &tree, node_offset_t no unescaped.erase(std::remove_if(unescaped.begin(), unescaped.end(), quote), unescaped.end()); - // If no non-alphanumeric char is left, use the unescaped version. + // If no non-"good" char is left, use the unescaped version. // 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. - if (std::find_if_not(unescaped.begin(), unescaped.end(), fish_iswalnum) == unescaped.end() && !unescaped.empty()) { + // 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'/'; }; + if (std::find_if_not(unescaped.begin(), unescaped.end(), goodchars) == + unescaped.end() && + !unescaped.empty()) { output.append(unescaped); } else { output.append(source, node.source_start, node.source_length);