I’ve recently moved to a new machine and now whenever I save a file (in Atom), any blank line that follows an indented line will have a similar indentation added to it.
I don’t format manually on the CL.
The machine change also came with a change from 1.7 to 1.12
My .formatter.exs has not changed in any way.
Does anyone know why this might be happening?
It’s starting to get rather irritating.
I don’t use mix format but I’ve just run it and it touched every file in the codebase with the exception of the ones that I have already affected through atom.
I’ll be discarding those changes.
Thank God for git
I checked the versions of the atom-elixir-formatter Atom package and it differs between the two machines but as far as I can tell this just runs mix format so I wouldn’t expect it to affect how formatting is actually carried out.
Am I wrong on this?
Atom may well have its own tabs and spaces logic that is being applied after the elixir formatter is running, I’m not sure. My point in having you run mix format wasn’t because I was trying to ruin your code base but rather to show you that it isn’t the thing adding the spaces.
I bet if you look at the file that has the spaces, and then run mix format, you’ll see that the spaces go away.
Should have said earlier, I’m amazed at the speed and helpfulness of the response @benwilson512, thanks.
Unfortunately that wasn’t the case mix format doesn’t affect the files that have the spaces and for the files that had none, it added them.
I might have to bite the bullet and let it do it’s thing for the entire codebase. My code reviewer keeps getting a shock whenever she sees a file with 100+ lines changed only to find that maybe three of them are actual code changes.
It’s not that big a deal but understanding how it works is more valuable to me than avoiding the issue.
Ah yeah, in my view the mix formatter should be used 100% on a code base, or not at all. It causes giant pains if it only fires when certain people touch the files. We even integrate it into our CI so that if a non formatted file is checked in the build fails. Helps catch issues early.
This is not what mix format does by default (and I don’t think it’s configurable either). I just tested it on a file, I added spaces/tabs for indentation on empty lines and mix format removed them. It must be something in your Atom config or some other thing that’s affecting it.