Skip to content

Commit

Permalink
add always return for do blocks with yas style
Browse files Browse the repository at this point in the history
  • Loading branch information
domluna committed Dec 1, 2024
1 parent aadf4cc commit 8ac2807
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/styles/blue/pretty.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ getstyle(s::BlueStyle) = s.innerstyle isa NoopStyle ? s : s.innerstyle

function options(::BlueStyle)
return (;
always_use_return = true,
always_use_return = false,
short_to_long_function_def = true,
long_to_short_function_def = false,
whitespace_ops_in_indices = true,
Expand Down
3 changes: 3 additions & 0 deletions src/styles/default/pretty.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,9 @@ function p_do(
elseif kind(c) === K"block"
s.indent += s.opts.indent
n = pretty(style, c, s, newctx(ctx; ignore_single_line = true), lineage)
if s.opts.always_use_return
prepend_return!(n, s)
end
add_node!(t, n, s; max_padding = s.opts.indent)
s.indent -= s.opts.indent
else
Expand Down
2 changes: 1 addition & 1 deletion test/options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@
str = """
map(arg1, arg2) do x, y
expr1
expr2
return expr2
end"""
@test fmt(str_, 4, length(str_) - 1; always_use_return = true) == str

Expand Down

0 comments on commit 8ac2807

Please sign in to comment.