{"action":"created","issue":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/2360","repository_url":"https://api.github.com/repos/crystal-lang/crystal","labels_url":"https://api.github.com/repos/crystal-lang/crystal/issues/2360/labels{/name}","comments_url":"https://api.github.com/repos/crystal-lang/crystal/issues/2360/comments","events_url":"https://api.github.com/repos/crystal-lang/crystal/issues/2360/events","html_url":"https://github.com/crystal-lang/crystal/issues/2360","id":143101945,"number":2360,"title":"Formatter should keep all trailing newlines (Was: Formatter removes end of file newlines.)","user":{"login":"vjdhama","id":2221174,"avatar_url":"https://avatars.githubusercontent.com/u/2221174?v=3","gravatar_id":"","url":"https://api.github.com/users/vjdhama","html_url":"https://github.com/vjdhama","followers_url":"https://api.github.com/users/vjdhama/followers","following_url":"https://api.github.com/users/vjdhama/following{/other_user}","gists_url":"https://api.github.com/users/vjdhama/gists{/gist_id}","starred_url":"https://api.github.com/users/vjdhama/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vjdhama/subscriptions","organizations_url":"https://api.github.com/users/vjdhama/orgs","repos_url":"https://api.github.com/users/vjdhama/repos","events_url":"https://api.github.com/users/vjdhama/events{/privacy}","received_events_url":"https://api.github.com/users/vjdhama/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/crystal-lang/crystal/labels/draft","name":"draft","color":"00B8B8"},{"url":"https://api.github.com/repos/crystal-lang/crystal/labels/formatter","name":"formatter","color":"d4c5f9"},{"url":"https://api.github.com/repos/crystal-lang/crystal/labels/RFC","name":"RFC","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-03-23T23:03:18Z","updated_at":"2016-03-24T18:56:52Z","closed_at":null,"body":"I tend to leave a newline at the end of files. I ran `crystal tool format` on my project and it removed the newline at the end, for all the files. I that desired behavior? \r\n\r\nI personally think it shouldn't. WDYT?"},"comment":{"url":"https://api.github.com/repos/crystal-lang/crystal/issues/comments/200970412","html_url":"https://github.com/crystal-lang/crystal/issues/2360#issuecomment-200970412","issue_url":"https://api.github.com/repos/crystal-lang/crystal/issues/2360","id":200970412,"user":{"login":"luislavena","id":4182,"avatar_url":"https://avatars.githubusercontent.com/u/4182?v=3","gravatar_id":"","url":"https://api.github.com/users/luislavena","html_url":"https://github.com/luislavena","followers_url":"https://api.github.com/users/luislavena/followers","following_url":"https://api.github.com/users/luislavena/following{/other_user}","gists_url":"https://api.github.com/users/luislavena/gists{/gist_id}","starred_url":"https://api.github.com/users/luislavena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luislavena/subscriptions","organizations_url":"https://api.github.com/users/luislavena/orgs","repos_url":"https://api.github.com/users/luislavena/repos","events_url":"https://api.github.com/users/luislavena/events{/privacy}","received_events_url":"https://api.github.com/users/luislavena/received_events","type":"User","site_admin":false},"created_at":"2016-03-24T18:56:51Z","updated_at":"2016-03-24T18:56:51Z","body":"@waj you're correct. I think the problem is the interpretation of what is considered *a new line*\r\n\r\nJust for the sake of clarification:\r\n\r\n```\r\nclass Foo\\n\r\nend\\n\r\n```\r\n\r\nThat, according to Git, is a proper terminated file (there is a new line indicator at the end of the file, as expected).\r\n\r\nNow, editors like Sublime will show a new line (3rd) when there isn't actually one, just because the presence of `\\n` in the last line\r\n\r\n![screenshot from 2016-03-24 15-53-06](https://cloud.githubusercontent.com/assets/4182/14027883/96265a96-f1d8-11e5-8c50-2b915491e815.png)\r\n\r\nSo that could be the root of the confusion. I personally have Sublime Text setting to add new line at the end (to avoid GCC and Git to complain about it) and when used the formatter, never got a complain from Git about missing the new line.\r\n\r\n@vjdhama can you tell us which editor are you using that is presenting this issue? or perhaps is that you prefer to end the file with 2 new lines?\r\n\r\n```\r\nclass Foo\\n\r\nend\\n\r\n\\n\r\n```\r\n\r\nCheers.\r\n"}}