mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 05:43:11 +00:00
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.
This commit is contained in:
parent
dc228432d2
commit
6deef37c66
1 changed files with 7 additions and 3 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue