From 9a53bf7d56380de6fccf40cd29dc42186d6dc85c Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 8 Aug 2020 18:29:50 -0700 Subject: [PATCH] fish_indent: indent line continuations For example: cmd \ arg Fixes one case from #7252 --- src/fish_indent.cpp | 4 ++++ tests/checks/indent.fish | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/fish_indent.cpp b/src/fish_indent.cpp index 8171bc565..e60f67448 100644 --- a/src/fish_indent.cpp +++ b/src/fish_indent.cpp @@ -400,6 +400,10 @@ struct pretty_printer_t { output.append(L" "); } output.append(L"\\\n"); + // Indent the line continuation (#7252). + current_indent += 1; + emit_space_or_indent(); + current_indent -= 1; } } diff --git a/tests/checks/indent.fish b/tests/checks/indent.fish index ae8ce32d5..a19b818eb 100644 --- a/tests/checks/indent.fish +++ b/tests/checks/indent.fish @@ -248,6 +248,25 @@ end #CHECK: {{ }}# comment #CHECK: end +echo -n ' +cmd \\ +continuation +' | $fish_indent +#CHECK: cmd \ +#CHECK: {{ }}continuation + +echo -n ' +begin +cmd \ +continuation +end +' | $fish_indent +#CHECK: begin +#CHECK: {{ }}cmd \ +#CHECK: {{ }}{{ }}continuation +#CHECK: end + + echo -n ' i\ f true