fish_indent: fix extra indent of continuation lines inside blocks

fish_indent used to increment the indentation level whenever we saw an escaped
newline.  This broke because of recent changes to parse_util_compute_indents().
Since parse_util_compute_indents() function already indents continuations
there is not much to do for fish_indent - we can simply query the indentation
level of the newline.  Reshuffle the code since we need to pass the offset
of the newline. Maybe this can even be simplified further.

Fixes #7720
This commit is contained in:
Johannes Altmanninger
2021-02-16 18:29:43 +01:00
parent 444c05dfb1
commit c0af8dae20
2 changed files with 27 additions and 15 deletions

View File

@@ -389,3 +389,19 @@ echo 'if true; and false; or true
end' | $fish_indent --check
echo $status
#CHECK: 0
echo -n '
function hello_continuations
echo cmd \
echo --opt1 \
echo --opt2 \
echo --opt3
end
' | $fish_indent
#CHECK: function hello_continuations
#CHECK: {{^}} echo cmd \
#CHECK: {{^}} echo --opt1 \
#CHECK: {{^}} echo --opt2 \
#CHECK: {{^}} echo --opt3
#CHECK: end