My elixir
code is as follows, the editor is vscode. When auto formating by shortcut key of alt-shift-f, a blank line will appear before the following Logger.debug
line. It will reappear even if it is deleted. Why it need a blank line here. Is it possible to not add the blank line?
test "calculate_line_point_test 1/4,1 point" do
whole_angle = :math.pi() / 4
start_angle = :math.atan(1 / 4)
n = 4
k = 1
result = InventoryMap.calculate_line_point(whole_angle, start_angle, n, k, 3, [])
# {2,10}
assert result == [
{2, 0.21866894587394198},
{3, 0.17985349979247828},
# [{2, 0.21866894587394198}]
{4, 0.1418970546041638}
]
#<---- blank line appear here
Logger.debug("get_angle: #{inspect(result)}")
end
CodePudding user response:
This behaviour has nothing to do with a particular editor, they all delegate to the language server and mix format
which is exposed by elixir itself (dig around Code.Fragment
.)
Formatter is the tool provided by elixir core team to standardize the code L&F. While it’s still possible to implement custom formatters and plug them into the existing project, I would strongly discourage doing that.
mix format
is the standard member of the CI pipeline and everyone expects it to perform in a common way (e. g. as after the standard mix format
without any custom formatters applied.) Just accept it :)