If the preference *Ensure new line at file end* is enabled, Geany adds a newline even to a completely empty file, so it’s impossible to save a file of 0 bytes.
While strictly speaking this does just what the preference label says, in practice the point of this feature, I think, is to ensure that *every line ends* with a newline, so it shouldn’t apply when there are no lines.
That’s what the other editors (nano, vi, emacs) do — they only add a newline to a non-empty file.
Seems fair, the new line at end of file is, I believe, to satisfy the C requirement (from the standard, my emphasis) "A source file that is __not empty__ shall end in a new-line character". That doesn't prevent a file containing just a newline of course.
Yes it prevents creating empty files.
Then again creating empty files with Geany isn't much of a use of its facilities :) Which is probably why it hasn't bothered anybody to date.
Discussion in #1810 has yielded the consensus to not change behavior here (WONTFIX)
Closed #1539.
github-comments@lists.geany.org