Skip to content

Commit

Permalink
Fix edge case with multiline lists with only a comment and no items (#94
Browse files Browse the repository at this point in the history
)
fredrikekre authored Nov 6, 2024
1 parent 36ac679 commit c9d74ea
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/runestone.jl
Original file line number Diff line number Diff line change
@@ -2485,13 +2485,16 @@ function indent_listlike(
end
# Kid just before the closing token should be a newline and it should be tagged with
# pre-dedent.
if close_idx - 1 == open_idx + 1
if idx_after_leading_nl == close_idx
# Just a single kid which should then have both leading and trailing newline
if any_kid_changed
# Modify this kid again by popping from the list and backtrack the stream
# Modify this kid again by popping from the list
kid = pop!(kids′)
seek(ctx.fmt_io, position(ctx.fmt_io) - span(kid))
else
kid = kids[close_idx - 1]
end
# Backtrack the stream
seek(ctx.fmt_io, position(ctx.fmt_io) - span(kid))
else
kid = kids[close_idx - 1]
end
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -397,6 +397,9 @@ end
# Non space whitespace (TODO: Not sure if a JuliaSyntax bug or not?)
@test format_string(String(UInt8[0x61, 0x20, 0x3d, 0x3d, 0x20, 0xc2, 0xa0, 0x62, 0x3a, 0x63])) ==
"a == b:c"
# Edge case with comment and no items
@test format_string("[# a\n]") == "[# a\n]"
@test format_string("[ # a\n]") == "[ # a\n]"
end

@testset "whitespace around ->" begin

2 comments on commit c9d74ea

@fredrikekre
Copy link
Owner Author

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 updated: JuliaRegistries/General/117521

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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.0 -m "<description of version>" c9d74ea61d45b34caf5f3de267b998fe63fe2c84
git push origin v1.0.0

Please sign in to comment.