diff --git a/lib/style/configs.ex b/lib/style/configs.ex index 14d0a2a..9725bcf 100644 --- a/lib/style/configs.ex +++ b/lib/style/configs.ex @@ -141,7 +141,7 @@ defmodule Styler.Style.Configs do def set_lines([{_, meta, _} = node | nodes], comments, start_line, n_acc, c_acc) do line = meta[:line] last_line = meta[:end_of_expression][:line] || Style.max_line(node) - # IO.puts "shifting by #{shift}" + {node, node_comments, comments} = if start_line == line do {node, [], comments} diff --git a/test/style/configs_test.exs b/test/style/configs_test.exs index 9a09c5a..f4c0cdb 100644 --- a/test/style/configs_test.exs +++ b/test/style/configs_test.exs @@ -166,7 +166,6 @@ defmodule Styler.Style.ConfigsTest do config :a, 2 config :a, 3 config :a, 4 - # comment # b comment config :b, 1 @@ -284,9 +283,9 @@ defmodule Styler.Style.ConfigsTest do # cd cd: :cd - config :b, :apples, :oranges # yeehaw config :b, :yeehaw, :meow + config :b, :apples, :oranges config :b, a: :b, # bcd @@ -325,6 +324,7 @@ defmodule Styler.Style.ConfigsTest do ad: :cd config :b, :apples, :oranges + # yeehaw config :b, :yeehaw, :meow @@ -335,6 +335,8 @@ defmodule Styler.Style.ConfigsTest do e: :f config :c, + # some junk after b, idk + # ca ca: :ca, # cb 1 diff --git a/test/style/set_lines_test.exs b/test/style/set_lines_test.exs deleted file mode 100644 index 283251e..0000000 --- a/test/style/set_lines_test.exs +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2024 Adobe. All rights reserved. -# This file is licensed to you under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. You may obtain a copy -# of the License at http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software distributed under -# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS -# OF ANY KIND, either express or implied. See the License for the specific language -# governing permissions and limitations under the License. - -defmodule Styler.Style.SetLinesTest do - @moduledoc false - use Styler.StyleCase, async: true, filename: "config/config.exs" - - test "sigh" do - {{_, _, ast}, comments} = - Styler.string_to_quoted_with_comments( - """ - import Config - - config :a, 1 - config :a, 2 - config :a, 3 - config :a, 4 - - # comment between - - # comment - # b comment - config :b, 1 - config :b, 2 - """, - "" - ) - - assert {sast, scomments} = Styler.Style.Configs.set_lines(ast, comments, 1, [], []) - assert comments == scomments - assert ast == sast - end -end