Closed m1dnight closed 2 weeks ago
I used the following to bisect this:
source.ex
defmodule SomeModule do
def render(assigns) do
~H"""
<div>
<div>
<script nonce={@csp_nonce}>
window.appConfig = window.appConfig || {}
window.appConfig.clientUpload = window.appConfig.clientUpload || {}
window.appConfig.clientUpload.flow = "<%= @flow %>"
<%= if @type == :files_client do %>
window.appConfig.clientUpload.client = <%= raw(Jason.encode!(JustifiedInternalApi.ClientView.render("client.json", %{client: @client}))) %>
window.appConfig.clientUpload.existingFiles = <%= raw(Jason.encode!(@existing_client_files)) %>
<% end %>
</script>
</div>
</div>
"""
end
end
script.sh
#!/bin/bash
mix deps.get
mix run -e "{f, _} = Mix.Tasks.Format.formatter_for_file(\"../source.ex\"); if f.(File.read!(\"../source.ex\")) == File.read!(\"../source.ex\"), do: System.halt(0), else: System.halt(1)"
Running git bisect run bash script.sh
points to this commit:
Environment
Actual behavior
When formatting a file, newlines are inserted. When the formatter is run again, the newlines are duplicated.
Using the example input:
Formatting once results in:
Formatting 10 times results in:
This happened with
phoenix_live_view
at 0.20.15, but not with 0.20.14.I think it will be related to these changes: https://github.com/phoenixframework/phoenix_live_view/compare/v0.20.14...v0.20.15#diff-463a21df4167ac1fea6a9c66d1cd80e22d32115a2c21b44c90f696bc09c9feb4
I can't really spot the cause right away, though.