Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Heptazhou committed Mar 9, 2024
1 parent 472a933 commit 9fca928
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
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 <dluna132@gmail.com>"]
version = "1.0.52"
version = "1.0.53"

[deps]
CSTParser = "00ebfdb7-1f24-5e51-bd34-a7502290713f"
Expand Down
7 changes: 6 additions & 1 deletion src/document.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ function Document(text::AbstractString)
# multiline comment of the form
# #=
#
# #=
# =#

idx = findfirst(x -> x == '\n', t.val) + 1
fc2 = findfirst(c -> !isspace(c), t.val[idx:end])
ws2 = fc2 === nothing ? ws : max(ws, fc2 - 1)

line = t.startpos[1]
offset = goffset
Expand All @@ -143,6 +147,7 @@ function Document(text::AbstractString)
comments[line] = (ws, cs[idx:end])
end
line += 1
ws = ws2
cs = ""
end
offset += 1
Expand Down
2 changes: 1 addition & 1 deletion src/print.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function print_inlinecomment(io::IOBuffer, fst::FST, s::State)
s.on || return
ws, v = get(s.doc.comments, fst.startline, (0, ""))
isempty(v) && return
v = v[end] == '\n' ? v[nextind(v, 1):prevind(v, end)] : v
v = v[end] == '\n' ? v[firstindex(v):prevind(v, end)] : v
if ws > 0
write(io, repeat(" ", ws))
elseif startswith(v, "#=") && endswith(v, "=#")
Expand Down
16 changes: 16 additions & 0 deletions test/issues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1814,4 +1814,20 @@
"""
@test format_text(s, SciMLStyle()) == s2
end

@testset "822" begin
s = """
ℯ #=
=#
"""
@test format_text(s) == s

s = """
begin
π => im #=
comment =#
end
"""
@test format_text(s) == s
end
end

0 comments on commit 9fca928

Please sign in to comment.