Skip to content

Commit 666b9e4

Browse files
committed
Fix handling of stab comments
1 parent 44ec807 commit 666b9e4

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

lib/elixir/lib/code/comments.ex

-15
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ defmodule Code.Comments do
354354
defp merge_mixed_comments({:->, _, [left, right]} = quoted, state) do
355355
start_line = get_line(right)
356356
end_line = get_end_line({:__block__, state.parent_meta, [quoted]}, start_line)
357-
block_start = get_line({:__block__, state.parent_meta, [quoted]})
358357

359358
{right, comments} =
360359
case right do
@@ -376,20 +375,6 @@ defmodule Code.Comments do
376375
end
377376
end
378377

379-
{quoted, comments} =
380-
case left do
381-
[] ->
382-
{leading_comments, comments} =
383-
split_leading_comments(comments, block_start, start_line)
384-
385-
quoted = append_comments(quoted, :leading_comments, leading_comments)
386-
387-
{quoted, comments}
388-
389-
_ ->
390-
{quoted, comments}
391-
end
392-
393378
quoted = put_args(quoted, [left, right])
394379

395380
{quoted, %{state | comments: comments}}

lib/elixir/lib/code/formatter.ex

+6-2
Original file line numberDiff line numberDiff line change
@@ -1886,9 +1886,13 @@ defmodule Code.Formatter do
18861886
comments = merge_algebra_with_comments(comments, @empty)
18871887

18881888
# If there are any comments before the ->, we hoist them up above the fn
1889-
doc = case comments do
1889+
doc =
1890+
case comments do
18901891
[] -> doc
1891-
[comments] -> line(comments, doc)
1892+
[comment] -> line(comment, doc)
1893+
comments ->
1894+
comments_doc = comments |> Enum.reduce(&line(&2, &1)) |> force_unfit()
1895+
line(comments_doc, doc)
18921896
end
18931897

18941898
{doc, state}

0 commit comments

Comments
 (0)