Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/options.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Base.@kwdef struct Options
yas_style_nesting::Bool = false
short_circuit_to_if::Bool = false
disallow_single_arg_nesting::Bool = false
preserve_single_line_if::Bool = false

function Options(args...)
opts = new(args...)
Expand Down
7 changes: 6 additions & 1 deletion src/styles/default/pretty.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1622,9 +1622,14 @@ function p_if(
add_node!(t, pretty(style, c, s, ctx, lineage), s)
elseif kind(c) === K"block"
s.indent += s.opts.indent
block_ctx = if s.opts.preserve_single_line_if
ctx
else
newctx(ctx; ignore_single_line = true)
end
add_node!(
t,
pretty(style, c, s, newctx(ctx; ignore_single_line = true), lineage),
pretty(style, c, s, block_ctx, lineage),
s;
max_padding = s.opts.indent,
)
Expand Down