Skip to content

Commit

Permalink
fix #760 (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
domluna authored Oct 4, 2023
1 parent ccc6712 commit f72bcf0
Show file tree
Hide file tree
Showing 3 changed files with 18 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.38"
version = "1.0.39"

[deps]
CSTParser = "00ebfdb7-1f24-5e51-bd34-a7502290713f"
Expand Down
8 changes: 8 additions & 0 deletions src/document.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ function Document(text::AbstractString)
cidx = nl2 + 1
end
end
elseif t.kind === Tokens.ERROR && startswith(t.val, "#=")
nlidx = findfirst(x -> x == '\n', t.val)
nlidx = nlidx === nothing ? length(t.val) : nlidx - 1
throw(
ErrorException(
"""Unable to format. Multi-line comment on line $(t.startpos[1]) is not closed.""",
),
)
elseif t.kind === Tokens.COMMENT
ws = 0
if prev_tok.kind === Tokens.WHITESPACE
Expand Down
9 changes: 9 additions & 0 deletions test/issues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1744,4 +1744,13 @@
"""
@test fmt(str, 4, 92, align_struct_field = true) == str
end

@testset "760" begin
s = """
foo() = nothing
#=
a = 10
"""
@test_throws ErrorException format_text(s)
end
end

0 comments on commit f72bcf0

Please sign in to comment.