elan-language / LanguageAndIDE

Apache License 2.0
3 stars 0 forks source link

If last line of program is a comment, the saved file is invalid #702

Closed richardpawson closed 3 weeks ago

richardpawson commented 3 weeks ago

(Reported by Nela)

If you create a file with a comment as the final line and save it, then attempt to load it again, the reload fails, because there is no final newline at the end of the last comment.

I notice that the renderAsSource for both global-comment and comment-statement do not have a \r unlike other frames. This is so that there is no blank line inserted between successive comments.

So the fix needs to be in FileImple.renderHashableContent(): add a test that the source ends in \r\n and, if not, appends it automatically.