Skip to content

Commit

Permalink
fix #728 (#735)
Browse files Browse the repository at this point in the history
  • Loading branch information
domluna committed Jun 7, 2023
1 parent f2a5bbe commit fd4fae3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/print.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,23 @@ function print_tree(
(nodes[i+2].typ === Block || nodes[i+2].typ === Begin)
if noindent
add_indent!(nodes[i+2], s, -s.opts.indent)
# this captures the trailing comment is not captured as being part of the block
if i + 4 <= length(nodes) && nodes[i+4].typ === NOTCODE
nodes[i+4].indent -= s.opts.indent
end
else
n.indent = nodes[i+2].indent
end
n.indent = nodes[i+2].indent
elseif i > 2 && (nodes[i-2].typ === Block || nodes[i-2].typ === Begin)
if noindent
add_indent!(nodes[i+2], s, -s.opts.indent)
add_indent!(nodes[i-2], s, -s.opts.indent)
else
n.indent = nodes[i-2].indent
end
n.indent = nodes[i-2].indent
end

if noindent
n.indent -= s.opts.indent
end
end

Expand Down
22 changes: 22 additions & 0 deletions test/issues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1660,4 +1660,26 @@
"""
@test fmt(s, 4, 92, always_use_return = true) == s
end
@testset "728" begin
s = """
begin
#! format: noindent
# This is OK
function foo end
# This is not
end
"""
@test fmt(s, 4, 92) == s

s = """
begin
#! format: noindent
end
"""
@test fmt(s, 4, 92) == s
end
end

2 comments on commit fd4fae3

@domluna
Copy link
Owner Author

@domluna domluna commented on fd4fae3 Jun 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/85079

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.34 -m "<description of version>" fd4fae31aa67bcfedf6a2a22753ff8034e27de67
git push origin v1.0.34

Please # to comment.