Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #757 #758

Merged
merged 1 commit into from
Sep 19, 2023
Merged
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "JuliaFormatter"
uuid = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
authors = ["Dominique Luna <[email protected]>"]
version = "1.0.36"
version = "1.0.37"

[deps]
CSTParser = "00ebfdb7-1f24-5e51-bd34-a7502290713f"
Expand Down
9 changes: 9 additions & 0 deletions src/align.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@ function align_struct!(fst::FST)

nlen = length(n[1])
ind = findfirst(x -> x.typ === OPERATOR, n.nodes)
# issue 757
# "foo
# """
# a::B
#
# This is parsed as a concatenated string of "foo" and ""
ind === nothing && continue

ws = n[ind].line_offset - (n.line_offset + nlen)

push!(g, n, i, n[ind].line_offset, nlen, ws)
Expand All @@ -216,6 +224,7 @@ function align_struct!(fst::FST)
binop = n[end]
nlen += length(binop[1])
ind = findfirst(x -> x.typ === OPERATOR, binop.nodes)
ind === nothing && continue
ws = binop[ind].line_offset - (n.line_offset + nlen)

push!(g, binop, i, binop[ind].line_offset, nlen, ws)
Expand Down
11 changes: 11 additions & 0 deletions test/issues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1727,4 +1727,15 @@
"""
@test format_text(str_, SciMLStyle()) == str
end

@testset "757" begin
str = """
struct Foo
\"foo
\"\"\"
foo::String
end
"""
@test fmt(str, 4, 92, align_struct_field = true) == str
end
end
Loading