Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Newline added on every save #289
I have the same issue, I think it happens when
I think Brittany indents a final newline, such that the former final newline isn't regarded as the final newline anymore, and a new final newline is inserted by vscode next time the buffer is saved, which then gets indented by brittany, and the cycle repeats...
lspitzner/brittany#25 has nothing to do with this.
I think @sheyll's analysis is close, although I am confused where the newline containing space comes from.
It is true that brittany adds a new line if the last line contained anything in the input (even if those contents were only spaces that don't get reproduced by brittany). But this stops after one iteration, as there now is a newline character at the end of the input. So idempotency is not violated from brittany's end alone.
There are two fixes to this: Stop brittany from adding a final newline and stop whatever else from adding a line containing space. I think both should be implemented. I have opened lspitzner/brittany#53.
As it turns out, lspitzner/brittany#53 was unrelated, although it had a similar cause. Brittany never exposed any newline-appending behaviour when the
But I think the cause is related: the plugin uses Text.lines instead of
So now I think the fix involves not using