Skip to content

Commit

Permalink
fix #757 (#758)
Browse files Browse the repository at this point in the history
  • Loading branch information
domluna authored Sep 19, 2023
1 parent 37d4079 commit e2159f5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
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

0 comments on commit e2159f5

Please sign in to comment.